-
Notifications
You must be signed in to change notification settings - Fork 191
Description
Issue
When enabling "Uncaught Exceptions breakpoint" with debugpy this lifetime extends exceptions and in return their traceback until the next unwind event afterwards. This leads to behaviour changes under the debugger. The following minimal reproducer shows this behaviour change
import weakref
class Test:
def test(self):
raise Exception
a = Test()
b = weakref.ref(a)
try:
a.test()
except:
pass
finally:
a = None
# None unless running under debugpy with "Uncaught Exceptions breakpoint" enabled
print(b())since Exception tracebacks contain a lot of references this can keep a lot of things alive for longer than expected.
This wasn't an issue prior to the sys.monitoring based implementation for Python 3.12.
Original Message
I am unsure what exactly changes since we didn't use debugpy in around a year. In the meantime we also switched from Python 3.11 to Python 3.13.
Our code base relies on objects being destroyed e.g. so signals are disconnected when debugging our code base.
When attempting to use debugpy again with our recent versions we experience crashes because the objects are kept alive via a frame object and so the signals aren't disconnected. Presumably this is caused by changes like the python 3.12 low impact monitoring.
Is it known what causes this + what would be the best way to avoid this?