Serhiy Storchaka <[email protected]> added the comment:
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
----------
stage: patch review ->
title: continue in finally with return in try results with segfault -> continue
and break in finally with return in try results with segfault
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue37830>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com