Get the latest tech news
PEP 760: No more bare excepts
👋 Hi everyone, As the evil twin of PEP 758: Allow `except` and `except*` expressions without parentheses, @brettcannon and me present you PEP 760: No more bare excepts. This PEP proposes disallowing bare except: clauses in Python’s exception-handling syntax. Currently, Python allows catching all exceptions with a bare except: clause, which can lead to overly broad exception handling and mask important errors. This PEP suggests requiring explicit exception types in all except clauses, pro...
I haven’t had time to look at the response from the PEP authors, but I would really like to preserve bare- except with an unconditional raise use case. Although it’s straightforward the implementation would be quite verbose as this implies doing an entire ast visitor just to detect raises below the bare except (in C). IMHO it’s OK to emit warnings left and right, but outright rejecting bare excepts after just 3 releases of deprecation period seems… not cool.
Or read this on Hacker News