0

I'm using Boost to embed Python in my application. For example, I want to check that the following function receives an integer and a string as the first and second parameters (the function is defined in C++).

someFunction(123, 'words')

If I find that the parameters are incorrect, how can I notify the scripter about which line they need to correct, for example?

2 Answers 2

3

If you wrap the function using usual def("someFunction",someFunction,...), caller will get automatically notified about c++ signature which could not be matched with objects passed from python, like this (the method takes one dictionary argument, is called with 3 numbers instead):

>>> scene.updateAttrs(1,2,3)

ArgumentError: Python argument types in
    Serializable.updateAttrs(Scene, int, int, int)
did not match C++ signature:
    updateAttrs(Serializable {lvalue}, boost::python::dict)

Can you post some code to see what is your problem?

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

Comments

1

Raise an exception with all the information you want them to know, just like you would in Python. In fact, that answer seems so obvious, it makes me think I'm missing something in your question.

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.