Bug in Py_Finalize() ?
Tim Peters
tim.one at home.com
Fri Mar 2 15:40:41 EST 2001
[Owen F. Ransen]
> I tried to report this bug to sorgeforge, signed up, but
> it kept on giving me page not found errors after I logged
> in....
Bless you for trying, anyway.
> Trying to find a bug in my C extension I ended up writing
> this loop:
>
> for (UINT i = 0 ; i < 10 ; i++) {
> Py_Initialize();
> Py_Finalize() ;
> }
>
> which crashes Python when i=8 with the message:
> Windows 32, VC++ program.
>
> Fatal Python error: UNREF invalid object
>
> My understanding is that I can use Py_Initialize() and
> Py_Finalize() in pairs to free up memory and to start
> with a clean interpreter each time I need it. And that
> is why I'd like to use Py_Finalise....
Please try this again with the lastest CVS version, or pick up 2.1b1 (we'll
be releasing that later today). Something "very much like this" got fixed
last month; here's Guido's checkin msg:
----------------------------
2001/02/20 21:43:24 gvanrossum Python/import.c
The code in PyImport_Import() tried to save itself a bit of work and
save the __builtin__ module in a static variable. But this doesn't
work across Py_Finalise()/Py_Initialize()! It also doesn't work when
using multiple interpreter states created with PyInterpreterState_New().
So I'm ripping out this small optimization.
This was probably broken since PyImport_Import() was introduced in
1997! We really need a better test suite for multiple interpreter
states and repeatedly initializing.
This fixes the problems Barry reported in Demo/embed/loop.c.
----------------------------
I'd try it for you right now, but I'm in the process of building the 2.1b1
Windows installer and won't have the bandwidth until that's done ...
just-enough-spare-cycles-to-write-email-between-reboots<wink>-ly y'rs - tim
More information about the Python-list
mailing list