pypsrp icon indicating copy to clipboard operation
pypsrp copied to clipboard

return in finally swallows exceptions

Open iritkatriel opened this issue 1 year ago • 1 comments

In https://github.com/jborean93/pypsrp/blob/d2a3eca257230e40354d39ca008639992f8495a4/src/psrp/_connection/wsman.py#L746 there is a return statement in a finally block, which would swallow any in-flight exception. and https://github.com/jborean93/pypsrp/blob/d2a3eca257230e40354d39ca008639992f8495a4/src/psrp/_connection/wsman.py#L1110

This means that if a BaseException (such as KeyboardInterrupt) is raised from the try body, or any exception is raised from an except: clause, 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 22:10 iritkatriel

Thanks for the information, it's certainly somewhat surprising but I can understand why it is happening and will have to update the code.

jborean93 avatar Oct 28 '24 19:10 jborean93