
Python 3.14 Updates
Python 3.14
Allow except and except* expressions without parentheses
Overview
The except and except* expressions now allow omitting parentheses when specifying multiple exception types and no as clause is used Python .
The rationale for PEP 758 is to reduce boilerplate and improve readability when catching multiple related errors, aligning single and grouped exception syntax Python .
Example Usage
This enables cleaner exception handling like:
try:
release_new_sleep_token_album()
except AlbumNotFound, SongsTooGoodToBeReleased:
print("Sorry, no new album this year.")
# The same applies to exception groups:
try:
release_new_sleep_token_album()
except* AlbumNotFound, SongsTooGoodToBeReleased:
print("Sorry, no new album this year.")
PEP 758 was contributed by Pablo Galindo and Brett Cannon and is now available in final form in Python 3.14
Disallow return/break/continue that exit a finally block
Overview
PEP 765 proposes to emit a SyntaxWarning when a return, break, or continue statement would transfer control outside of a finally block, withdrawing support for such patterns in Python 3.14 (PEPs).
The PEP highlights that these control‑flow instructions inside finally are rare—just a few instances per million lines of real‑world code—and often lead to unintended exception swallowing (PEPs) .
Because silently dropped exceptions can slip through testing, PEP 765 encourages developers to handle cleanup logic explicitly rather than relying on jumps out of finally clauses (PEPs) .
Example Usage
def compute():
try:
return "result-from-try"
finally:
return "result-from-finally"
# SyntaxWarning: 'return' will exit 'finally' block
Conclusion
Both changes reflect Python’s commitment to evolving the language towards clearer and safer idioms without sacrificing expressiveness
Documentation DocumentationMore Articles
Key Words:
Pythonupdatepython 3.14 Developers