From: Jason D. <jd...@ba...> - 2012-05-18 12:49:29
|
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 I suppose this must mean I'm still doing something obviously wrong. -Jason ________________________________________ From: Bob Hood [bh...@co...] Sent: Friday, May 18, 2012 8:40 AM To: swi...@li... Subject: Re: [Swig-user] Best way to debug python error 'XXX undetected error'? On 5/18/2012 6:14 AM, Jason Dictos wrote: > %typemap(out) list<FileObj> > { > $result = PyList_New(0); > 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); > } > } Hmm.. You're creating a list with 0 items, but then using PyList_SetItem() to set values at indices that don't yet exist. You might try using PyList_Append() instead of PyList_SetItem() when starting with an empty list and see if that improves anything. 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 Swi...@li... https://lists.sourceforge.net/lists/listinfo/swig-user 'Like' us on Facebook for exclusive content and other resources on all Barracuda Networks solutions. Visit http://barracudanetworks.com/facebook |