I am wrapping my get/set methods with an attribute/member for Python as follows:


%attribute(MyObject, double, value, get, set)


Prior to using %attribute I was handling exceptions thrown from the C++ MyObject::set like this:


%exception MyObject::set {

   try {


   } catch (RangeException &e) {

         PyErr_SetString(PyExc_ValueError, const_cast<char*>(e.what()));

         return NULL;




This works fine without %attribute, but no longer works because the set method is called through this macro, thus the code to handle the exception is never inserted:




What is the correct way to use these two constructs together?


Thanks for any hints.