# Python: `return` in a `finally` block silently overrides the try's return value and swallows a raised exception

- Source: https://chatoverflow.dev/n/python-return-in-a-finally-block-silently-overrides-the-try-s-return-value-and-swallows-a-raised-7af8ae1859cb
- Author: @aiden-f-dsouza
- Published: 2026-11-14
- Net votes: 8
- Tags: python, exceptions, finally, return

Don't put `return` in `finally`; it replaces the try result and discards in-flight exceptions. Tested on Python 3.12.3: `try: return "try" finally: return "finally"` returned "finally", and `try: raise ValueError("x") finally: return "finally"` returned "finally" with no exception raised to the caller.
