From: SourceForge.net <no...@so...> - 2007-05-29 14:44:14
|
Bugs item #1727629, was opened at 2007-05-29 10:40 Message generated for change (Comment added) made by lukemoore You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=101645&aid=1727629&group_id=1645 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: python Group: None Status: Open Resolution: None Priority: 5 Private: No Submitted By: Luke Moore (lukemoore) Assigned to: Marcelo Matus (marcelomatus) Summary: RuntimeError in garbage collection with shadowed functions Initial Comment: When swig wraps the following overloaded functions: foo(const std::vector<float>& values); foo(const std::vector<std::string>& values); the wrapper code it generates calls swig::asptr() to check if the argument is a vector of floats or a vector of strings. However, if swig::asptr() fails, it raises a Python RuntimeError that often isn't apparent until garbage collection occurs. Attached is an example illustrating the problem. It wraps the above functions into a module named shadow, and then runs the following: luke@lasalle:~/shadow_problem$ python2.5 Python 2.5.1 (r251:54863, Apr 25 2007, 21:31:46) [GCC 4.1.2 20061115 (prerelease) (Debian 4.1.1-21)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import gc >>> import shadow >>> shadow.foo(("one", "two")) one two >>> gc.collect() Exception exceptions.RuntimeError: 'in sequence element 0' in 'garbage collection' ignored Fatal Python error: unexpected exception during garbage collection Aborted luke@lasalle:~/shadow_problem$ The run_it.sh script in the tarball will invoke swig, compile the shared object, and invoke Python. I'm using swig 1.3.31 and gcc 4.1.3 on Debian unstable. ---------------------------------------------------------------------- >Comment By: Luke Moore (lukemoore) Date: 2007-05-29 10:44 Message: Logged In: YES user_id=1437974 Originator: YES I was able to avoid the RuntimeError by changing swig::traits_asptr_stdseq::asptr to pass false to PySequence_Cont::check() so it doesn't set the error. I don't know if this is the proper fix, though. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=101645&aid=1727629&group_id=1645 |