[Cython] __del__ not called on Python exit
Robert Bradshaw
robertwb at math.washington.edu
Fri Nov 28 07:40:39 CET 2008
On Nov 27, 2008, at 9:29 AM, Stephane DROUARD wrote:
> Hi,
>
> With the following file "foo.py":
>
> class Foo:
> def __init__(self):
> print "__init__"
>
> def __del__(self):
> print "__del__"
>
> foo = Foo()
> del foo
> foo = Foo()
>
>> python -c "import foo"
> __init__
> __del__
> __init__
> __del__
>
> When foo.py is Cythonized (0.10.2):
>> python -c "import foo"
> __init__
> __del__
> __init__
>
> __del__ is not called when the Python exits.
>
> I tried using "--cleanup 1", but it hangs, trying to write at
> address 0...
The cleanup level goes all the way up to 3, but it still doesn't seem
to catch everything. It's also (as you've noticed) a bit unsafe.
Somehow module dictionaries in extension modules don't get
deallocated. This is a known issue, if you (or anyone else) has any
ideas I'd love to hear them. I just made a ticket http://
trac.cython.org/cython_trac/ticket/142
- Robert
More information about the Cython-dev
mailing list