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

This turned out more accurate than I could have ever guessed at the time. I didnt know that syntax warnings werent filtered properly, that uv doesn’t precompile by default, and that in spite of that and that these were decisions that were supposed to limit the disruptiveness, that when they did not function as intended that people would keep defending tossing a linter rule into the language without a plan to make it an error.

This is effectively more disruptive than traditional deprecation for the few affected projects.

CPython will emit a SyntaxWarning in version 3.14, and we leave it open whether, and when, this will become a SyntaxError

The PEP never committed to making it an error, which to me feels like this was just a way to do an end run around normal deprecation since you are now claiming that was always the intent for it to later be an error.

@hugovk the article there covers only the simplest case of try/finally. Nobody using it correctly has an issue with figuring out the right way to rewrite this, it’s the fact that working code has to be rewritten with no prior warning for what is amounts to a linter rule because it is impacting downstream code that is the problem. The warning breaks CI use of warning as errors immediately because this change was made without anyone verifying that warning filters would work (they don’t for this)

cases with nested try/finally while supressing errors require significantly more changes to properly retain the intened behavior, as outer finally blocks run even after returning in an inner one. This is a rather natural way to ensure ordered cleanup of things that must not fail to cleanup, and some libraries do intentionally suppress certain errors that their users wouldn’t be able to do anything about.

1 Like