[Python-bugs-list] [ python-Bugs-660707 ] Problems with reference counting and exec
noreply@sourceforge.net
noreply@sourceforge.net
Wed, 01 Jan 2003 07:26:09 -0800
Bugs item #660707, was opened at 2003-01-01 11:26
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=660707&group_id=5470
Category: Python Interpreter Core
Group: Python 2.2
Status: Open
Resolution: None
Priority: 5
Submitted By: Daniel (kamek)
Assigned to: Nobody/Anonymous (nobody)
Summary: Problems with reference counting and exec
Initial Comment:
When using exec to parse an arbitrary string, Python
seems to have some problems on keeping the reference
count. The sample below shows a problem when the
specified string is not a valid Python expression, and
would be better for testing in the Python interpreter (~
preceding lines represents indentation):
#BEGIN
clas MyClass:
~def __del__(self):
~~print 'Deleting object'
def f():
~# create a new instance
~obj = MyClass()
~# now, raise an exception
~exec "any invalid line"
f()
#END
We get an exception, but in no moment we see the
destructor being called. The most curious, then, is that if
we raise another exception from the interpreter (just type
anything), we get the destructor right before the
exception information.
There's also a reference count problem that happens
even when the line for exec is valid, but I couldn't
manage to reproduce it outside of my project yet.
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=660707&group_id=5470