You've already forked python-uncompyle6
mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2025-08-03 00:45:53 +08:00
Handle 3.6+ EXTENDED_ARGs for POP_JUMP_IF... instructions
This commit is contained in:
BIN
test/bytecode_3.6/10_long_pop_jump.pyc
Normal file
BIN
test/bytecode_3.6/10_long_pop_jump.pyc
Normal file
Binary file not shown.
50
test/simple_source/bug36/10_long_pop_jump.py
Normal file
50
test/simple_source/bug36/10_long_pop_jump.py
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
# From 3.6 _markupbase.py
|
||||||
|
|
||||||
|
# Bug is that the routine is long enough that POP_JUMP_IF_FALSE instruciton has an
|
||||||
|
# EXTENDED_ARG intruction before it and we weren't picking out the jump offset properly
|
||||||
|
|
||||||
|
def parse_declaration(self, i):
|
||||||
|
if rawdata[j:j] in ("-", ""):
|
||||||
|
return -1
|
||||||
|
n = len(rawdata)
|
||||||
|
if rawdata[j:j+2] == '-':
|
||||||
|
return self.parse_comment(i)
|
||||||
|
elif rawdata[j] == '[':
|
||||||
|
return self.parse_marked_section(i)
|
||||||
|
else:
|
||||||
|
decltype, j = self._scan_name(j, i)
|
||||||
|
if j < 0:
|
||||||
|
return j
|
||||||
|
if decltype == "d":
|
||||||
|
self._decl_otherchars = ''
|
||||||
|
while j < n:
|
||||||
|
c = rawdata[j]
|
||||||
|
if c == ">":
|
||||||
|
data = rawdata[i+2:j]
|
||||||
|
if decltype == "d":
|
||||||
|
self.handle_decl(data)
|
||||||
|
else:
|
||||||
|
self.unknown_decl(data)
|
||||||
|
return j + 1
|
||||||
|
if c in "'":
|
||||||
|
m = _declstringlit_match(rawdata, j)
|
||||||
|
if not m:
|
||||||
|
return -1
|
||||||
|
j = m.end()
|
||||||
|
elif c in "a":
|
||||||
|
name, j = self._scan_name(j, i)
|
||||||
|
elif c:
|
||||||
|
j += 1
|
||||||
|
elif c == "[":
|
||||||
|
if decltype == "d":
|
||||||
|
j = self._parse_doctype_subset(j + 1, i)
|
||||||
|
elif decltype in {"attlist", "linktype", "link", "element"}:
|
||||||
|
self.error("unsupported '[' char in %s declaration" % decltype)
|
||||||
|
else:
|
||||||
|
self.error("unexpected '[' char in declaration")
|
||||||
|
else:
|
||||||
|
self.error(
|
||||||
|
"unexpected %r char in declaration" % rawdata[j])
|
||||||
|
if j < 0:
|
||||||
|
return j
|
||||||
|
return -1
|
@@ -716,6 +716,8 @@ class Scanner3(Scanner):
|
|||||||
else:
|
else:
|
||||||
if self.get_target(jump_back, 0) >= next_line_byte:
|
if self.get_target(jump_back, 0) >= next_line_byte:
|
||||||
jump_back = self.last_instr(start, end, self.opc.JUMP_ABSOLUTE, start, False)
|
jump_back = self.last_instr(start, end, self.opc.JUMP_ABSOLUTE, start, False)
|
||||||
|
|
||||||
|
# This is wrong for 3.6+
|
||||||
if end > jump_back+4 and self.is_jump_forward(end):
|
if end > jump_back+4 and self.is_jump_forward(end):
|
||||||
if self.is_jump_forward(jump_back+4):
|
if self.is_jump_forward(jump_back+4):
|
||||||
if self.get_target(jump_back+4) == self.get_target(end):
|
if self.get_target(jump_back+4) == self.get_target(end):
|
||||||
@@ -753,8 +755,8 @@ class Scanner3(Scanner):
|
|||||||
'start': after_jump_offset,
|
'start': after_jump_offset,
|
||||||
'end': end})
|
'end': end})
|
||||||
elif op in self.pop_jump_tf:
|
elif op in self.pop_jump_tf:
|
||||||
start = offset + instruction_size(op, self.opc)
|
start = offset + instruction_size(op, self.opc)
|
||||||
target = self.get_target(offset)
|
target = self.insts[inst_index].argval
|
||||||
rtarget = self.restrict_to_parent(target, parent)
|
rtarget = self.restrict_to_parent(target, parent)
|
||||||
prev_op = self.prev_op
|
prev_op = self.prev_op
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user