PEP 765: Disallow return/break/continue that exit a finally block

There are some unique issues related to implementation of the PEP 765 warnings. Other warnings are emitted either in the lexer/tokenizer or in the code generator. But the PEP 765 warnings are generated in a separate step which is executed twice when use ast.parse() for getting an AST and then compile() to compile the AST. Compilation emits multiple warnings in the finally block · Issue #131927 · python/cpython · GitHub

The fix for this issue was not correct – it introduced other bugs (Syntax warnings can be swallowed in import · Issue #139640 · python/cpython · GitHub), and is incompatible with solutions for other issue (Better module info for SyntaxWarnings during AST parsing · Issue #135801 · python/cpython · GitHub). Both of them affect ability to discover and fix the original PEP 765 issue. So it should be reverted, but then we should apply an alternative solution for warning duplication.

5 Likes