[New-bugs-announce] [issue42762] infinite loop resulted by "yield"
Xinmeng Xia
report at bugs.python.org
Sun Dec 27 23:38:15 EST 2020
New submission from Xinmeng Xia <xiaxm at smail.nju.edu.cn>:
Let's see the following program:
============================
def foo():
try:
yield
except:
yield from foo()
for m in foo():
print(i)
===========================
Expected output:
On line"print(i)", NameError: name 'i' is not defined
However, the program will fall into infinite loops when running it on Python 3.7-3.10 with the error messages like the following.(no infinite loop on Python 3.5 and Python 3.6)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/xxm/Desktop/nameChanging/report/test1.py", line 160, in <module>
print(i)
RuntimeError: generator ignored GeneratorExit
Exception ignored in: <generator object foo at 0x7fb30ff639e0>
Traceback (most recent call last):
File "/home/xxm/Desktop/nameChanging/report/test1.py", line 160, in <module>
print(i)
RuntimeError: generator ignored GeneratorExit
Exception ignored in: <generator object foo at 0x7fb30ff63a50>
Traceback (most recent call last):
File "/home/xxm/Desktop/nameChanging/report/test1.py", line 160, in <module>
print(i)
RuntimeError: generator ignored GeneratorExit
Exception ignored in: <generator object foo at 0x7fb30ff63ac0>
Traceback (most recent call last):
File "/home/xxm/Desktop/nameChanging/report/test1.py", line 160, in <module>
print(i)
......
----------------------------------------------------------------------
----------
components: Interpreter Core
messages: 383882
nosy: xxm
priority: normal
severity: normal
status: open
title: infinite loop resulted by "yield"
type: crash
versions: Python 3.10, Python 3.7, Python 3.8, Python 3.9
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue42762>
_______________________________________
More information about the New-bugs-announce
mailing list