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 vstinner
Recipients martius, ned.deily, r.david.murray, serhiy.storchaka, vstinner, yselivanov
Date 2016-11-23.23:11:25
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
Oh wow, the bug is tricky.

_PyGen_yf() checks if the next instruction is YIELD_FROM using code[f_lasti+2]. The problem is that WORDCODE kept f_lasti == -1 for a frame not executed yet: f_lasti+2 is 1 in this case.

Problem: code[1] is not an operation code, but the argment. Python 3.6 bytecode now uses the "wordcode" format: 16-bit units of (operation, argument).

The obvious and simple fix is to add a special case for f_lasti==-1 in _PyGen_yf(): see attached patch.

pygen_yf.patch fixes the crash.


Another much larger change would be to change f_lasti to -2... In the rewiew of the huge WORDCODE patch, if I recall correctly, I asked Demur to use -1 for backward compatibility. Or maybe I asked to kept the backward compatibility at the Python level using a getter converting -2 to -1... I don't recall correctly.

See for wordcode.
Date User Action Args
2016-11-23 23:11:25vstinnersetrecipients: + vstinner, ned.deily, r.david.murray, serhiy.storchaka, yselivanov, martius
2016-11-23 23:11:25vstinnersetmessageid: <>
2016-11-23 23:11:25vstinnerlinkissue28782 messages
2016-11-23 23:11:25vstinnercreate