Open Atokulus opened 5 years ago
For the sake of documentation:
A finally clause is always executed before leaving the try statement, whether an exception has occurred or not. When an exception has occurred in the try clause and has not been handled by an except clause (or it has occurred in an except or else clause), it is re-raised after the finally clause has been executed. The finally clause is also executed “on the way out” when any other clause of the try statement is left via a break, continue or return statement. - Python 2.7: Defining Clean-up Actions
Hi there!
https://github.com/ljean/modbus-tk/blob/41073499f57bdbeaa89f3fae687dfa368c67a876/modbus_tk/utils.py#L38
The exception handling here seems not necessary as the Exception will be rethrown after the
finally
clause anyway.Furthermore: In case of an exception, the traceback is originating from the given line in
utils.py
, meaning that we cannot determine the originating location of line of code causing the exception. This can make debugging cumbersome.Example here for some exception I provoked:
Just remove
Best regards & Thx for your commitment Markus