[docs] [issue15355] generator docs should mention already-executing exception

Chris Jerdonek report at bugs.python.org
Fri Aug 17 23:01:54 CEST 2012


Chris Jerdonek added the comment:
Good suggestion, David. Here is such sample test code. It is adapted from the sample code for "ValueError: generator already executing" included in PEP 255:
def test_gen(call_gen_method):
 def gen():
 call_gen_method(me)
 yield 1
 me = gen()
 try:
 me.__next__()
 except Exception as e:
 print(repr(e))
test_gen(lambda g: g.__next__())
test_gen(lambda g: g.send(1))
test_gen(lambda g: g.throw(OSError))
test_gen(lambda g: g.close())
This outputs:
ValueError('generator already executing',)
ValueError('generator already executing',)
ValueError('generator already executing',)
ValueError('generator already executing',)
----------
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue15355>
_______________________________________


More information about the docs mailing list

AltStyle によって変換されたページ (->オリジナル) /