PyCon UK 2025

The tale of PEP 765: SyntaxWarning on `return` in `finally`
2025-09-20 , Main stage

The next version of Python emits a SyntaxWarning when return is used in a finally block. This is a small change to the language, with an interesting history. This talk tells that story.


One of the new features of Python 3.14, which will be released in October, is that it emits a SyntaxWarning if return, break or continue appear in a finally block. This is a minor change to the language, with an interesting story. In fact, it was already proposed and rejected in the past.

This talk explains the change that PEP 765 introduces to Python 3.14, and the motivation for it. It then reflects on the history of this change, and the reasons that PEP 601, which proposed it for version 3.8, was rejected. Covering the discussions and the research that led to the decision to accept this change by way of PEP 765, the talk also sheds light on the PEP process and the way that such decisions are made by the Core Developers and the CPython Steering Council.


What level of experience do you expect from your audience for this session?:

Basic

I am a CPython Core Developer, working at Microsoft on the faster cpython team.