1

I am using a software called Mitsuba. It comes along with a Python implementation, wrapped with Boost. This line in Python:

scene = SceneHandler.loadScene(fileResolver.resolve("model.xml"), paramMap)

yields an error. The type of fileResolver.resolve is fs::path and the type of paramMap is ParameterMap according to the documentation.

The function signature in the C++ code is:

SceneHandler::loadScene(const fs::path &filename, const ParameterMap &params) 

The error is:

Traceback (most recent call last):
  File "...\foo.py", line 22, in <module>
    scene = SceneHandler.loadScene(fileResolver.resolve("model.xml"), paramMap)
ArgumentError: Python argument types in
    SceneHandler.loadScene(str, StringMap)
did not match C++ signature:
    loadScene(class boost::filesystem2::basic_path<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,struct boost::filesystem2::path_traits>, class std::map<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,struct mitsuba::SimpleStringOrdering,class std::allocator<struct std::pair<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const ,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > > > >)

What further investigations can I make? Do you know where the problem comes from?

2 Answers 2

2

Unfortunately it's not clear which of the arguments is causing a problem.

According to the error message you have, the return type of fileResolver.resolve is apparently str, not boost::filesystem::basic_path. What you want to look at is where Mitsuba defines its Boost.Python interface to see if there is a "converter" registered for turning Python strings into boost::fs::path objects. If not, you'll have to figure out what the right way of getting a Python object that's convertible to the correct type is for this library.

For the second argument, you have basically the same checks to make, unless StringMap is already a Boost.Python type (what does type(paramMap.__class__) return?). It looks like ParameterMap is a typedef for

`std::map<std::string, std::string, mitsuba::SimpleStringOrdering>`

But again, there must be a Boost.Python converter registered that can do the conversion from the Python type.

Sign up to request clarification or add additional context in comments.

4 Comments

So type(paramMap.__class__) returns <type 'Boost.Python.class'>, so it shouldn't be a problem in the python file. Let me check the rest.
type(fileResolver.__class__) returns the same. What does a "converter" look like?
But type(fileResolver.resolve("model.xml")) is just str, right? Then that's the one with the missing from-Python converter. Looking at the Mitsuba source, there is a to-Python converter for fs::path, and this asymmetry is the source of the problem you're having. You should probably report this as a bug.
Do you mean there is something missing in those lines? bp::to_python_converter<fs::path, path_to_python_str>(); bp::implicitly_convertible<std::string, fs::path>();
0

Note that this bug has been fixed for a while now—there is now an implicit conversion that goes both ways between fs::path and std::string when crossing the C++/Python barrier.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.