[Python] VC++ 7.1 workaround needed in boost/python/class.hpp

I'm running into problems with Visual C++ 7.1 and class_<..>::add_property() in Boost.Python. The issue pops up in this bit o' code: class_<Graph> graph(name); graph .add_property("vertex_properties", &py_get_vertex_properties<Graph>, "A Python dictionary mapping from vertex property names to\n" "property maps. These properties are \"attached\" to the graph\n" "and will be pickled or serialized along with the graph.") .add_property("edge_properties", &py_get_edge_properties<Graph>, "A Python dictionary mapping from edge property names to\n" "property maps. These properties are \"attached\" to the graph\n" "and will be pickled or serialized along with the graph.") In particular, the compiler chokes when instantiating add_property(), because it can't tell that the third parameter is a docstring (instead of a setter). At line 304 of boost/python/class.hpp (RC_1_33_0 branch), there is a workaround for all Visual C++ versions prior to 7.1 that avoids this problem: if I switch the "1300" to "1310" to include VC++ 7.1, everything works fine. Unfortunately, I wasn't able to create a small test case that exhibits the problem. If you really, really want to reproduce the problem, you can grab the BGL-Python bindings that triggered it with: svn co https://svn.osl.iu.edu/svn/projects/viz/bgl-python Should we do the version bump in the workaround, or could that cause problems? Doug

Douglas Gregor <doug.gregor@gmail.com> writes:
I'm running into problems with Visual C++ 7.1 and class_<..>::add_property() in Boost.Python. The issue pops up in this bit o' code:
class_<Graph> graph(name); graph .add_property("vertex_properties", &py_get_vertex_properties<Graph>, "A Python dictionary mapping from vertex property names to\n" "property maps. These properties are \"attached\" to the graph\n" "and will be pickled or serialized along with the graph.") .add_property("edge_properties", &py_get_edge_properties<Graph>, "A Python dictionary mapping from edge property names to\n" "property maps. These properties are \"attached\" to the graph\n" "and will be pickled or serialized along with the graph.")
In particular, the compiler chokes when instantiating add_property(), because it can't tell that the third parameter is a docstring (instead of a setter). At line 304 of boost/python/class.hpp (RC_1_33_0 branch), there is a workaround for all Visual C++ versions prior to 7.1 that avoids this problem: if I switch the "1300" to "1310" to include VC++ 7.1, everything works fine.
Unfortunately, I wasn't able to create a small test case that exhibits the problem.
Can you add test case that's just large enough to reproduce it to one of the Boost.Python regression tests?
If you really, really want to reproduce the problem, you can grab the BGL-Python bindings that triggered it with:
svn co https://svn.osl.iu.edu/svn/projects/viz/bgl-python
Should we do the version bump in the workaround, or could that cause problems?
Go ahead and bump the version; we'll see tests fail if there are any problems. However, I'd most like to see a test fail before you make the change ;-) -- Dave Abrahams Boost Consulting www.boost-consulting.com
participants (2)
-
David Abrahams
-
Douglas Gregor