question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Forbid `BaseException` in `except` block

See original GitHub issue

Rule 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:closed
  • Created 5 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
AlexArcPycommented, Oct 5, 2018

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 😃

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found