[Python-Dev] ref leak w/except hooks (original) (raw)

Brett Cannon brett at python.org
Thu Mar 2 19:09:28 CET 2006


On 3/2/06, Neal Norwitz <nnorwitz at gmail.com> wrote:

The following code leaks a reference. Original test case from Lib/test/testsys.py in testoriginalexcepthook.

import sys, StringIO eh = sys.excepthook try: raise ValueError(42) except ValueError, exc: exctype, excvalue, exctb = sys.excinfo() eh(exctype, None, None)

Which can be simplified to::

from sys import excepthook as eh

try: raise BaseException except: eh(BaseException, None, None)

It fails if the first argument to sys.excepthook is either a built-in exception or a classic class. it looks like strings and new-style classes do not trigger it.

-Brett



More information about the Python-Dev mailing list