andfoy / pywinpty

Pseudoterminals for Windows in Python
MIT License
118 stars 27 forks source link

break in finally swallows exceptions #461

Open iritkatriel opened 1 month ago

iritkatriel commented 1 month ago

In https://github.com/andfoy/pywinpty/blob/694ad0b498b23b3386d1e30296f82a734c014fe3/winpty/ptyprocess.py#L358 there is a break statement in a finally block, which would swallow any in-flight exception.

This means that if any exception (including a 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.