"Qun Cao" <quncao@gmail.com> writes:
Hi Everyone,
I created a simple class wrapper like this
BOOST_PYTHON_MODULE(PythonTest) { class_<MyClass,boost::noncopyable>("pMyClass", init<char const*>()); }
When I try to initialize pMyClass in python, I got this error:
Traceback (most recent call last): File "<stdin>", line 1, in ? RuntimeError: unidentifiable C++ exception
MyClass is part of a third party GameEngine, I can successfully use it in C++. Can anyone suggest what might went wrong here?
Either: a. Your C++ class threw some exception for which there's no pre-registered Boost.Python exception translator, or b. You're running on windows and your C++ code crashed. To find out if this is the case, add the following code to your module source file: # ifdef _MSC_VER # pragma warning(push) # pragma warning(disable:4297) # pragma warning(disable:4535) extern "C" void straight_to_debugger(unsigned int, EXCEPTION_POINTERS*) { throw; } extern "C" void (*old_translator)(unsigned, EXCEPTION_POINTERS*) = _set_se_translator(straight_to_debugger); # pragma warning(pop) # endif That will cause crashes to look like crashes rather than exceptions. -- Dave Abrahams Boost Consulting www.boost-consulting.com