Author chris.jerdonek
Recipients chris.jerdonek, docs@python, meador.inge, ncoghlan, r.david.murray, terry.reedy
Date 2012-08-17.21:01:53
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1345237314.03.0.0700693433442.issue15355@psf.upfronthosting.co.za>
In-reply-to
Content
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',)
History
Date User Action Args
2012-08-17 21:01:54chris.jerdoneksetrecipients: + chris.jerdonek, terry.reedy, ncoghlan, r.david.murray, meador.inge, docs@python
2012-08-17 21:01:54chris.jerdoneksetmessageid: <1345237314.03.0.0700693433442.issue15355@psf.upfronthosting.co.za>
2012-08-17 21:01:53chris.jerdoneklinkissue15355 messages
2012-08-17 21:01:53chris.jerdonekcreate