Fix stack effect#43
Conversation
Codecov Report
@@ Coverage Diff @@
## master #43 +/- ##
=========================================
Coverage ? 93.67%
=========================================
Files ? 17
Lines ? 2623
Branches ? 0
=========================================
Hits ? 2457
Misses ? 166
Partials ? 0
Continue to review full report at Codecov.
|
This is a subtle but critical detail. Thanks for the reminder! |
MatthieuDartiailh
left a comment
There was a problem hiding this comment.
Some minor comment edits suggestion (this new Github feature is great !) but otherwise this is good to go. Please check the length of the lines of my edits github does not provide yet rulers.
Fix https://github.com/vstinner/bytecode/issues/38.
@MatthieuDartiailh
If
dis.stack_effectdoesn't convert oparg when unnecessarily, we wouldn't get this error.https://github.com/python/cpython/blob/137b0632dccb992ca11e9445142fb33a29c33a51/Modules/_opcode.c#L38
However, for we cannot change the standard module immediately, we have to avoid passing the oparg when we didn't calculate the operand of an instruction.
For instance,
Instr('LOAD_CONST', 0xFFFFFFFFFFFFFFF)might donate bytecodeLOAD_CONST 1, and when we calculate its stack effect, we should usedis.stack_effect(100, 1)instead ofdis.stack_effect(100, 0xFFFFFFFFFFFFFFF).Actually we cannot convert
0xFFFFFFFFFFFFFFFto1when calculating stack effects, fortunately if we have to convert the oparg ofInstrto the operand of bytecode instruction, it means that the oparg is insignificant to the result.Thanks @serhiy-storchaka for
https://github.com/python/cpython/blob/137b0632dccb992ca11e9445142fb33a29c33a51/Python/compile.c#L859.