Bob Hood | 18 May 2012 15:16
Picon
Gravatar

Re: Best way to debug python error 'XXX undetected error'?

On 5/18/2012 6:47 AM, Jason Dictos wrote:
Yeah woops, haven't had my morning coffe or something. Its now like so: %typemap(out) list<FileObj> { $result = PyList_New($1.size()); int index = 0; for(auto iter = $1.begin(); iter != $1.end(); iter++) { auto resultobj = SWIG_NewPointerObj((new FileObj(static_cast< const FileObj& >(*iter))), SWIGTYPE_p_FileObj, SWIG_POINTER_OWN | 0 ); PyList_SetItem($result, index++, resultobj); } } I am however still getting the weird error: XXX undetected error Traceback (most recent call last): File "<stdin>", line 1, in <module> File "TestModify.py", line 30, in <module> print 'Children of root (local): ' SystemError: ..\Objects\listobject.c:206: bad argument to internal function

Well, not having a simple example that reproduces the issue that I can compile and test for myself, I'm only grasping at what might happening.  I am wondering, however, if something is not happening to the elements you are placing into the list before they are accessed in the Python environment.

Assuming the incoming list<FileObj> array is non-volatile (i.e., it's not going away before the end of the function of which your typemap is part), instead of this:
auto resultobj = SWIG_NewPointerObj((new FileObj(static_cast< const FileObj& >(*iter))), SWIGTYPE_p_FileObj, SWIG_POINTER_OWN | 0 );
try something like this:
auto resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(&(static_cast<const FileObj&>(*iter))), SWIGTYPE_p_FileObj, 0);
and see what happens.  I may not have the code exactly right, and it may not fix the problem, but I'm just curious.

Render me gone, ||| Bob ^(===)^ ---------------------------------oOO--(_)--OOo--------------------------------- I'm not so good with advice...can I interest you in a sarcastic comment?
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Swig-user mailing list
Swig-user <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/swig-user

Gmane