This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Local references not released after exception
Type: resource usage Stage:
Components: Interpreter Core Versions: Python 2.6
process
Status: closed Resolution: wont fix
Dependencies: Superseder:
Assigned To: Nosy List: James.Bowman, alex, georg.brandl
Priority: normal Keywords:

Created on 2010-10-20 04:01 by James.Bowman, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Messages (3)
msg119187 - (view) Author: James Bowman (James.Bowman) Date: 2010-10-20 04:01
import sys

def foo():
    x = [o] * 100
    raise ArithmeticError

o = "something"
print sys.getrefcount(o)
try:
    foo()
except ArithmeticError:
    pass
print sys.getrefcount(o)

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

Gives:

4
104


Looking at the CPython source, FrameObject's deallocator does actually decrement refcounts of its locals and arguments.  Guessing that the FrameObject is not being deallocated.
msg119188 - (view) Author: Alex Gaynor (alex) * (Python committer) Date: 2010-10-20 04:58
That's because in Python 2.5 at that point in the code sys.exc_info() still points at the traceback (and by extension, the frame) thus x is not deallocated yet.  I don't think this is a bug.
msg119190 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2010-10-20 06:22
Alex is correct.  (You can prove that by raising and catching another exception before the second getrefcount().)
History
Date User Action Args
2022-04-11 14:57:07adminsetgithub: 54359
2010-10-20 06:22:07georg.brandlsetstatus: open -> closed

nosy: + georg.brandl
messages: + msg119190

resolution: wont fix
2010-10-20 04:58:36alexsetnosy: + alex
messages: + msg119188
2010-10-20 04:01:45James.Bowmancreate