a Python bug in processing __del__ method ??
From: Baoqiu Cui (baoqiu_at_gmail.com)
Date: 01/31/05
- Next message: Bryan: "Re: Regarding exception handling"
- Previous message: tjv_at_hotmail.com: "Image stats - going from Matlab to Python"
- Next in thread: Fredrik Lundh: "Re: a Python bug in processing __del__ method ??"
- Reply: Fredrik Lundh: "Re: a Python bug in processing __del__ method ??"
- Reply: Steven Bethard: "Re: a Python bug in processing __del__ method ??"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 30 Jan 2005 22:46:51 -0800
Today I was playing with a small Python program using Python 2.4
on Cygwin (up-to-date version, on Windows XP), but ran into a
strange error on the following small program (named bug.py):
-------------------------------
#!/usr/bin/python
class Person:
population = 0
def __del__(self):
Person.population -= 1
peter = Person()
-------------------------------
The error returned is this:
$ python bug.py
Exception exceptions.AttributeError: "'NoneType' object has no
attribute 'population'" in <bound method Person.__del__ of
<__main__.Person instance at 0xa0c9fec>> ignored
However, if I rename variable name 'peter' to something like 'peter1'
or 'david', the error is gone. Looks to me the
error only happens to variable name 'peter'.
Does anyone know what is wrong? Is this a bug only on Cygwin?
- Baoqiu
- Next message: Bryan: "Re: Regarding exception handling"
- Previous message: tjv_at_hotmail.com: "Image stats - going from Matlab to Python"
- Next in thread: Fredrik Lundh: "Re: a Python bug in processing __del__ method ??"
- Reply: Fredrik Lundh: "Re: a Python bug in processing __del__ method ??"
- Reply: Steven Bethard: "Re: a Python bug in processing __del__ method ??"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|