[Python-bugs-list] [ python-Bugs-516965 ] __del__ is not called correctly

noreply@sourceforge.net noreply@sourceforge.net
Wed, 13 Feb 2002 05:45:34 -0800


Bugs item #516965, was opened at 2002-02-13 05:39
You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=516965&group_id=5470

Category: Python Interpreter Core
Group: Python 2.2
Status: Open
Resolution: None
Priority: 5
Submitted By: Christoph Wiedemann (wiedeman)
Assigned to: Nobody/Anonymous (nobody)
Summary: __del__ is not called correctly

Initial Comment:
Hello,

I found some strange behaviour in classes which provide their own destructor. The python version is 2.2, compiled with gcc 3.0.1 running on linux (kernel 2.2.18, glibc 2.2). Following an interactive python session:

>>> class A:
...  def __init__(self):
...   print "const"
...  def __del__(self):
...   print "dest"
...
>>> a = A()
const
>>> a
dest
<__main__.A instance at 0x81c9894>
>>> del a
>>> 

As you can see, the destructor is called, before the  object is deleted. On a Python 2.1 version, the behaviour is correct (the destructor is called _after_ 'del a')

Bye,
Christoph Wiedemann

----------------------------------------------------------------------

>Comment By: Guido van Rossum (gvanrossum)
Date: 2002-02-13 05:45

Message:
Logged In: YES 
user_id=6380

I can't reproduce this. Can you try this in a clean session?
I bet you can't, either.

Most likely, the "dest" output you see is from a *previous*
object that was saved in the "last output value register",
the built-in "_".


----------------------------------------------------------------------

You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=516965&group_id=5470