On Mon, Jun 29, 2026 at 1:56 PM Derick Rethans <[email protected]> wrote:

> I think I am not in favour of the following:
>
> - Deprecate returning from a finally block
>
> If somebody uses a `return` in a `finally` block, than this could just
> as well be intentional.
>

Hi Derick,

Yes, as you have probably already seen in the RFC, 9 out of the 12
instances across the top ~5000 packages
were intentional, but the proposal is not really aimed at intent.
Deprecating it takes no capability away from anyone doing this on purpose,
since the same result can still
be expressed in other ways, sometimes by just moving the `return` out of
the `finally`, but at the same time it protects
the people who do not pay attention to it (which could even be some of
those deliberately using it today, once they add a `return` or a `throw` in
the `try` later and its result silently disappears).

I also want to bring up again that even though I am suggesting a
deprecation, I am still genuinely interested to know whether someone
feels a warning, or even a notice, would fit better, so that if the
deprecation gets voted down we would at least have an impression of where
people stand.

The main point here is that *silently* discarding the in-flight state,
without giving a single hint about it, is a footgun, and that silent part
is really the concern here.
A `return` in `finally` quietly discarding an in-flight return value, and
more importantly an in-flight exception, so a thrown error can just
disappear with nothing reported anywhere.

Regards,
Osama

Reply via email to