espressif / esptool

Espressif SoC serial bootloader utility
https://docs.espressif.com/projects/esptool
GNU General Public License v2.0
5.6k stars 1.39k forks source link

return in finally swallows exceptions (ESPTOOL-948) #1025

Closed iritkatriel closed 3 weeks ago

iritkatriel commented 1 month ago

Operating System

NA

Esptool Version

master branch

Python Version

NA

Full Esptool Command Line that Was Run

NA

Esptool Output

NA

What is the Expected Behaviour?

Avoid return in finally.

More Information

In https://github.com/espressif/esptool/blob/8298cdcc68a8063df1ca932d42e21555e15269b3/esptool/cmds.py#L158 there is a return statement in a finally block, which would swallow any in-flight exception.

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

Other Steps to Reproduce

No response

Honza0297 commented 4 weeks ago

Hello @iritkatriel and thank you for reporting this!
We will look into this and fix it.