◐ Shell
clean mode source ↗

Message 349579 - Python tracker

Note, that we have a regression in 3.8. There is a use case for "break" in "finally", and such code is even used in the stdlib. And who know in what third-party code it is used. In specific circumstances (see msg349513) it now can cause a crash. Other example:

import contextlib
def simple():
    with contextlib.nullcontext():
        for number in range(2):
            try:
                return number
            finally:
                break

simple()

It just raise an exception in 3.8, not crash:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "<stdin>", line 7, in simple
TypeError: 'range_iterator' object is not callable