PyDev.Debugger icon indicating copy to clipboard operation
PyDev.Debugger copied to clipboard

return in finally swallows exceptions

Open iritkatriel opened this issue 1 year ago • 1 comments

In https://github.com/fabioz/PyDev.Debugger/blob/7d6e6e68670277c63d7b8f64cb73688f963f0663/pydevd_attach_to_process/winappdbg/event.py#L1478 and https://github.com/fabioz/PyDev.Debugger/blob/7d6e6e68670277c63d7b8f64cb73688f963f0663/pydevd_attach_to_process/winappdbg/event.py#L1635 there is a return statement in a finally block, which would swallow any in-flight exception.

This means that if any exception (including BaseException such as KeyboardInterrupt) is raised from the try body, it will not propagate on as expected.

See also https://docs.python.org/3/tutorial/errors.html#defining-clean-up-actions.

iritkatriel avatar Oct 24 '24 14:10 iritkatriel

Hi @iritkatriel, thank you for the issue report... now, this will likely not be fixed in pydevd because that code isn't really used...

At this point just a teeny-tiny bit of winappdbg is actually used in pydevd (some win32 wrapping in the attach to process to inject a dll into the target process), and I think 99% of the code could be removed -- at this point it'd probably make sense to just port over the needed definitions and remove everything else, but this takes time and ends up being very much low priority vs other things, so, not sure if it'll ever be done -- I accept PRs though ;)

fabioz avatar Oct 28 '24 16:10 fabioz