[issue45241] python REPL leaks local variables when an exception is thrown

2021-09-19 Thread Ian Henderson
Ian Henderson added the comment: Ah, you're right -- it looks like the 'objs' global is what's keeping these objects alive. Sorry for the noise. -- stage: -> resolved status: open -> closed ___ Python tracker <https://bugs.python.org/i

[issue45241] python REPL leaks local variables when an exception is thrown

2021-09-19 Thread Ian Henderson
New submission from Ian Henderson : To reproduce, copy the following code: import gc gc.collect() objs = gc.get_objects() for obj in objs: try: if isinstance(obj, X): print(obj) except NameError: class X: pass def f(): x = X() raise