[karmic][regression] def_readonly on static property results in AttributeError at import time

Bug #421380 reported by Václav Šmilauer
10
This bug affects 1 person
Affects Status Importance Assigned to Milestone
boost-defaults (Ubuntu)
New
Undecided
Unassigned

Bug Description

Compiling simple module wrapping static data member results in AttributeError when importing the module:

$ cat foo.cc
#include<boost/python.hpp>
struct Foo{
 static int bar;
};
int Foo::bar=3;

BOOST_PYTHON_MODULE(foo){
 boost::python::class_<Foo>("Foo",boost::python::init<>()).def_readonly("bar",Foo::bar);
}

$ g++ -o foo.so -I/usr/include/python2.6 -fPIC -shared -lboost_python-mt foo.cc
$ PYTHONPATH=. python -c 'import foo'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
AttributeError: 'Boost.Python.StaticProperty' object attribute '__doc__' is read-only

This bug (?) was described first at c++-sig in the http://thread.gmane.org/gmane.comp.python.c++/13979 thread.

Karmic only; no other tested distribution (hardy,jaunty,lenny,squeeze,sid) affected. Using different g++ version on karmic makes no difference.

Installed version libboost-python1.38-dev=1.38.0-6ubuntu4

tags: added: karmic regression-release
Revision history for this message
Anderson Lizardo (lizardo) wrote :

Renato found a workaround for the issue:

http://thread.gmane.org/gmane.comp.python.c++/13979/focus=14000

Can you try that with your testcase?

Revision history for this message
Václav Šmilauer (eudoxos) wrote :

The workaround compiles, but doesn't give expected results: it only work on instances, but not on types. With def_readonly, I would be able to use both

Vector3.UNIT_X
Vector3().UNIT_X

but with the workaround, only Vector3().UNIT_X will work.

Any other progress?

Revision history for this message
Scott Howard (showard314) wrote :

Thank you for taking the time to report this bug and helping to make Ubuntu better. This particular bug has already been reported and is a duplicate of bug 457688, so it is being marked as such. Please look at the other bug report to see if there is any missing information that you can provide, or to see if there is a workaround for the bug. Additionally, any further discussion regarding the bug should occur in the other report. Please continue to report any other bugs you may find.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.