[C++-sig] strange registry behavior
Jonathan Wang
jontwang at gmail.com
Mon Dec 18 17:56:52 CET 2006
I'm using code from
scitbx/include/scitbx/boost_python/container_conversions.h to register
automatic conversions to/from C++ container types to Python lists. However,
I'm seeing some extremely strange behavior - my conversion doesn't seem to
actually be found at call time.
The C++ code that registers the conversion:
from_python_sequence<vector<double>, variable_capacity_policy>();
to_tuple_mapping<vector<double> >();
tuple_mapping<vector<double>, variable_capacity_policy>();
I intentionally registered the conversion twice to get an error message that
the conversion was in fact registered:
>>> import vector as v
/home/jwang1/eqvol/Analytic2/python/vector.py:1: RuntimeWarning: to-Python
converter for std::vector<double, std::allocator<double> > already
registered; second conversion method ignored.
But when I make a call that returns a vector<double>, I get:
>>> baz = foo + bar
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "/home/jwang1/eqvol/Analytic2/python/vector.py", line 75, in __add__
return Vector(extract.getResult(calc))
TypeError: No Python class registered for C++ class std::vector<double,
std::allocator<double> >
Does this make any sense? How can Python complain that the to-Python
converter was registered twice if
it can't find the converter at runtime?
I get the same error if I don't cause the error on registration (i.e. only
having the tuple_mapping... line).
Thanks,
Jonathan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/cplusplus-sig/attachments/20061218/0f993cd9/attachment.htm>
More information about the Cplusplus-sig
mailing list