You've already forked python-uncompyle6
mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2025-08-03 00:45:53 +08:00
Python 3.4 assertion handling. Improve verify
3.4 has jump optimization like 3.5. verify.py: show mismatch on verification mismatch
This commit is contained in:
@@ -134,16 +134,19 @@ class Scanner3(scan.Scanner):
|
||||
bytecode = Bytecode(co, self.opc)
|
||||
|
||||
# Scan for assertions. Later we will
|
||||
# turn 'LOAD_GLOBAL' to 'LOAD_ASSERT' for those
|
||||
# assertions
|
||||
# turn 'LOAD_GLOBAL' to 'LOAD_ASSERT'.
|
||||
# 'LOAD_ASSERT' is used in assert statements.
|
||||
self.load_asserts = set()
|
||||
bs = list(bytecode)
|
||||
n = len(bs)
|
||||
for i in range(n):
|
||||
inst = bs[i]
|
||||
|
||||
if inst.opname == 'POP_JUMP_IF_TRUE' and i+1 < n:
|
||||
next_inst = bs[i+1]
|
||||
# We need to detect the difference between
|
||||
# "raise AssertionError" and
|
||||
# "assert"
|
||||
if inst.opname == 'POP_JUMP_IF_TRUE' and i+3 < n:
|
||||
next_inst = bs[i+3]
|
||||
if (next_inst.opname == 'LOAD_GLOBAL' and
|
||||
next_inst.argval == 'AssertionError'):
|
||||
self.load_asserts.add(next_inst.offset)
|
||||
|
Reference in New Issue
Block a user