[C++-sig] [Boost.Python] Importing twice causes error in MSVS with Boost.Python extension?

Lawrence Spector Lawrence.Spector at CanfieldSci.com
Wed Aug 15 21:57:15 CEST 2007


Actually, I figured this one out after some more testing.  Apparently I had set my paths in such a way that this worked.  I did the import in two different ways, and effectively, it tried to do both, then had an error because of it.

As an example, I was doing the equivalent of this:

import Package1.Module1

and then later:

import Module1

where Module1 is the same package, but specified differently.  I did this in the same script file.  That caused a double-import and thus the error.

-Lawrence

From: c++-sig-bounces at python.org [mailto:c++-sig-bounces at python.org] On Behalf Of Lawrence Spector
Sent: Wednesday, August 15, 2007 10:49 AM
To: Development of Python/C++ integration
Subject: [C++-sig] [Boost.Python] Importing twice causes error in MSVS with Boost.Python extension?

In one case I use "PyImport_ImportModule".  Later on, I do "PyRun_String".  Either way, same deal.  I import the module and the first time it succeeds.  The second time it blows up deep down in boost.  Ultimately an an assert fails, which can be traced down to boost::python::convert::registry::insert failing on an assertion of slot == 0 (line 160).  Before I go any further, has anyone else seen this problem before?  It doesn't happen on every module, just one particular one.  I even went to the trouble and removing everything it was exposing, with the same effect.  One other thing I'm doing is I have an __init__.py file in the directory, which does a "from <library> import *", as described in the tutorial.  One other interesting thing of note, is if it do it from IDLE and import this module twice, it seems to work.

Any ideas?  If not, I'll try to come up with a test case to reproduce.

Thanks in advance,

Lawrence
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/cplusplus-sig/attachments/20070815/79671f60/attachment.htm>


More information about the Cplusplus-sig mailing list