No, it is not about template-related error messages :-)...

I am wrapping a class:
#include <boost/python.hpp>

struct X {
   X() : _x(0) {}
   int get() const { return _x; }
   int _x;
};

BOOST_PYTHON_MODULE(Test) {
   class_<X>("X")
       .def("get", &X::get)
   ;
}

and testing it with python:
x = X();
print x.get()
print x.get

Obviously, the error is that I forgot '()' in the second get(). I am getting this error message:

0
<bound method X.get of <Test.X object at 0x2b0db13d4cb0>> Is there a way to give user a more friendly error message in such case, with at least a line number where it happened?

Note that if mistype the attribute name, I am getting something I much nicer:

Traceback (most recent call last):
 File "test.py", line 5, in <module>
   print x.foo
AttributeError: 'X' object has no attribute 'foo'

_______________________________________________
Cplusplus-sig mailing list
Cplusplus-sig@python.org
http://mail.python.org/mailman/listinfo/cplusplus-sig

Reply via email to