pycdc
pycdc copied to clipboard
fix: fix py27 RAISE_VARARGS_A cause pycdc crash
In python 2.7, some times have JUMP_FORWARD after RAISE_VARARGS, and sometimes not, we should check if we are in the end of if block
JUMP_FORWARD example:
Object Name: _check_closed
Arg Count: 1
Locals: 1
Stack Size: 2
Flags: 0x00000043 (CO_OPTIMIZED | CO_NEWLOCALS | CO_NOFREE)
[Names]
'closed'
'ValueError'
[Var Names]
'self'
[Free Vars]
[Cell Vars]
[Constants]
'Raises a ValueError if the underlying file object has been closed.\n\n '
'I/O operation on closed file.'
None
[Disassembly]
0 LOAD_FAST 0: self
3 LOAD_ATTR 0: closed
6 POP_JUMP_IF_FALSE 24
9 LOAD_GLOBAL 1: ValueError
12 LOAD_CONST 1: 'I/O operation on closed file.'
15 CALL_FUNCTION 1
18 RAISE_VARARGS 1
21 JUMP_FORWARD 0 (to 24)
24 LOAD_CONST 2: None
no JUMP_FORWARD example:
404 STORE_ATTR 25: compress
407 JUMP_FORWARD 17 (to 427)
410 LOAD_GLOBAL 26: IOError
413 LOAD_CONST 14: 'Mode '
416 LOAD_FAST 2: mode
419 BINARY_ADD
420 LOAD_CONST 15: ' not supported'
423 BINARY_ADD
424 RAISE_VARARGS 2
427 LOAD_FAST 4: fileobj
430 LOAD_FAST 0: self
433 STORE_ATTR 27: fileobj
436 LOAD_CONST 8: 0
This crash cause by https://github.com/zrax/pycdc/pull/561
Please avoid force pushes/rebases. Old comments are marked as outdated otherwise and makes it harder for reviewers to keep track of what changes have been reviewed and what haven't.