I have a C++ value type wrapped with Boost.Python which has a concept of a NULL value. The relevant parts of the wrapper code appear as follows:
class_<TCurrency> currency( "TCurrency" )
.def( init<long>() )
.def( init<const std::string&>() )
<...>;
Currently, trying to create a NULL instance in Python by passing None
to the __init__()
method causes the C++ ctor accepting a const string reference to be called with an invalid reference. (&arg == NULL
)
Is it possible to trap the case where None
is being passed to a constructor and handle it gracefully or at least to throw a meaningful exception before my program crashes?
Using Boost 1.36 and Python 2.6.2.