[issue43683] Handle generator (and coroutine) state in the bytecode.
Damien George
report at bugs.python.org
Wed Oct 20 23:12:43 EDT 2021
Damien George <damien.p.george at gmail.com> added the comment:
It looks like this change introduced a subtle, and maybe intended (?), behavioural change.
Consider (from MicroPython's test suite):
def f():
n = 0
while True:
n = yield n + 1
print(n)
g = f()
try:
g.send(1)
except TypeError:
print("caught")
print(g.send(None))
print(g.send(100))
print(g.send(200))
This used to work prior to commit b37181e69209746adc2119c471599a1ea5faa6c8. But after that commit it fails on the print(g.send(None)) because the generator is now stopped.
----------
nosy: +dpgeorge
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue43683>
_______________________________________
More information about the Python-bugs-list
mailing list