[Python-Dev] new unbounded memory leak in exception handling?

Greg Hewgill greg at hewgill.com
Tue Nov 17 19:14:02 CET 2009


On Tue, Nov 17, 2009 at 08:40:37AM -0500, R. David Murray wrote:
> I think you want to take a look at PEP 3134.  And then please file a doc
> bug to have someone update the documentation of sys.exc_info, since the
> advice in the warning box is no longer valid in Python 3.

Thanks for the pointer, I understand the cause now. I had read the
warning in the description of sys.exc_info, but I hadn't realised that
Python was (now) implicitly saving the traceback for me. I was able to
solve this memory leak by explicitly clearing __traceback__:

    except E:
        # get exception value in a python2/3 portable way
        a = sys.exc_info()[1]
        a.__traceback__ = None

I have added a doc bug issue for this: http://bugs.python.org/issue7340

Greg Hewgill
http://hewgill.com


More information about the Python-Dev mailing list