This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author bru
Recipients Rosuav, benjamin.peterson, bru, ezio.melotti, gvanrossum, serhiy.storchaka, vstinner
Date 2015-03-02.11:16:22
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1425294983.2.0.351520065113.issue23192@psf.upfronthosting.co.za>
In-reply-to
Content
Here are the operations being emitted (line, macro used and eventual argument):

>>> f = lambda: (yield 5)
3487: ADDOP_O LOAD_CONST e->v.Num.n
3472: ADDOP YIELD_VALUE
1907: ADDOP_IN_SCOPE POP_TOP
4349: ADDOP_O LOAD_CONST Py_None
4350: ADDOP RETURN_VALUE
1457: ADDOP_O LOAD_CONST (PyObject*)co
1458: ADDOP_O LOAD_CONST qualname
1459: ADDOP_I MAKE_FUNCTION args
4349: ADDOP_O LOAD_CONST Py_None
4350: ADDOP RETURN_VALUE
>>> def g(): return (yield 5)
... 
3487: ADDOP_O LOAD_CONST e->v.Num.n
3472: ADDOP YIELD_VALUE
2533: ADDOP RETURN_VALUE
1457: ADDOP_O LOAD_CONST (PyObject*)co
1458: ADDOP_O LOAD_CONST qualname
1459: ADDOP_I MAKE_FUNCTION args
4349: ADDOP_O LOAD_CONST Py_None
4350: ADDOP RETURN_VALUE

So there's an extra POP_TOP + LOAD_CONST Py_NONE for the lambda version that throws away the "123" (in the exemple).

The attached patch (0001-...) fixes it. However please note that I'm not knowledgable about that part of the code and devised the patch empirically.
Moreover a test should probably added but I did not know where (test_dis? tried and failed... see patch 0002-...).
History
Date User Action Args
2015-03-02 11:16:23brusetrecipients: + bru, gvanrossum, vstinner, benjamin.peterson, ezio.melotti, Rosuav, serhiy.storchaka
2015-03-02 11:16:23brusetmessageid: <1425294983.2.0.351520065113.issue23192@psf.upfronthosting.co.za>
2015-03-02 11:16:23brulinkissue23192 messages
2015-03-02 11:16:23brucreate