Problem embedding in small Win32 App

Gabriel Genellina gagsl-py2 at yahoo.com.ar
Fri Jul 27 15:59:02 EDT 2007


En Fri, 27 Jul 2007 16:06:32 -0300, Brad Johnson  
<Brad.Johnson at ballardtech.com> escribió:

>       PyObject* o = PyDict_GetItemString(_d, "_outcatcher");
>       PyObject* a = PyObject_GetAttrString(o, "data");
>       ::MessageBox(NULL, PyString_AsString(a), _T(""), NULL);
>
> However, it only works twice. On the third try, I get an access
> violation trying to access the stdout object (for a print statement).
> The pointer appears to be valid, but all of the data has overwritten
> with 0xDBDBDBDB, with obvious consequences.

By far, the most common problem extending/embedding Python is to do wrong  
reference counts.
Read http://docs.python.org/ext/refcounts.html again (I hope you already  
did!) and make sure you don't hold a pointer to an object without  
incrementing its reference count, by example.
If you can shrink your application to the minimum code that shows the  
problem, try posting it here.

-- 
Gabriel Genellina




More information about the Python-list mailing list