[issue44895] refleak test failure in test_exceptions

Irit Katriel report at bugs.python.org
Tue Aug 17 12:05:33 EDT 2021


Irit Katriel <iritkatriel at gmail.com> added the comment:

I'm pretty sure the frame locals is involved. 

This leaks (not a is being re-raised, not b):

---------------------
def test_no_hang_on_context_chain_cycle2():
    class A(Exception): pass
    class B(Exception): pass

    try:
        try:
            raise A()
        except A as _a:
            a = _a
            try:
                raise B() 
            except B as _b:
                b = _b
        raise a 
    except A: 
        pass
---------------------

But this doesn't leak:

---------------------
def test_no_hang_on_context_chain_cycle2():
    class A(Exception): pass
    class B(Exception): pass

    try:
        try:
            raise A()
        except A as _a:
            a = _a
            try:
                raise B() 
            except B as _b:
                pass # b = _b  <== not saving b in a local
        raise a 
    except A: 
        pass
---------------------

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue44895>
_______________________________________


More information about the Python-bugs-list mailing list