intentionality - complete
This rule raises an issue when a bare except:
, an except BaseException
or an except SystemExit
block does not re-raise the exception caught.
A SystemExit
exception is raised when sys.exit()
is called. This exception is used to signal the interpreter to exit. The exception is expected to propagate up until the program stops. It is possible to catch this exception in order to perform, for example, clean-up tasks. It should, however, be raised again to allow the interpreter to exit as expected. Not re-raising such exception could lead to undesired behaviour.
A bare except:
statement, i.e. an except
block without any exception class, is equivalent to except BaseException
. Both statements will catch every exceptions, including SystemExit
. It is recommended to catch instead a more specific exception. If it is not possible, the exception should be raised again.
It is also a good idea to re-raise the KeyboardInterrupt
exception. Similarly to SystemExit
,KeyboardInterrupt
is used to signal the interpreter to exit. Not re-raising such exception could also lead to undesired behaviour.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4