Forbid `BaseException` in `except` block
See original GitHub issueRule request
Thesis
We need to forbid except BaseException:
handlers.
Reasoning
We can silence system exit and keyboard interrupt with this handler. It is almost the same as raw except:
block.
Related: https://help.semmle.com/wiki/pages/viewpage.action?pageId=1608527
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (5 by maintainers)
Top Results From Across the Web
How to prevent "too broad exception" in this case?
When catching exceptions, mention specific exceptions whenever possible instead of using a bare except: clause. For example, use: try: import ...
Read more >Built-in Exceptions — Python 3.11.1 documentation
In Python, all exceptions must be instances of a class that derives from BaseException. In a try statement with an except clause that...
Read more >Except block handles 'BaseException' - CodeQL - GitHub
BaseException has three important subclasses, Exception from which all errors and normal exceptions derive, KeyboardInterrupt which is raised when the user ...
Read more >"Exception" and "BaseException" should not be raised
When you raise Exception or BaseException in a function the caller will have to add an except Exception or except BaseException and re-raise...
Read more >"try ... except ... else ... finally ..." in Python - nkmk note
In Python, try and except are used to handle exceptions (= errors detected during execution). With try and except, even if an exception...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I’ve started working on this. I am very knew to the
wemake-python-styleguide
source code which I am currently exploring, so it won’t be done any time soon… Will let you know when I stuck 😃Closed via https://github.com/wemake-services/wemake-python-styleguide/commit/58cfab4a23d54d0c61d2879c161a4d2dc9985096