You've already forked python-uncompyle6
mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2025-08-02 16:44:46 +08:00
Use attr insead of pattrr for non-strings
This commit is contained in:
BIN
test/bytecode_3.3_run/05_long_literals.pyc
Normal file
BIN
test/bytecode_3.3_run/05_long_literals.pyc
Normal file
Binary file not shown.
BIN
test/bytecode_3.6_run/05_long_literals.pyc
Normal file
BIN
test/bytecode_3.6_run/05_long_literals.pyc
Normal file
Binary file not shown.
@@ -230,10 +230,13 @@ class Scanner3(Scanner):
|
||||
|
||||
for j in range(collection_start, i):
|
||||
if insts[j].opname not in (
|
||||
"LOAD_ASSERT",
|
||||
"LOAD_CODE",
|
||||
"LOAD_CONST",
|
||||
"LOAD_FAST",
|
||||
"LOAD_GLOBAL",
|
||||
"LOAD_NAME",
|
||||
"LOAD_STR",
|
||||
):
|
||||
return None
|
||||
|
||||
@@ -376,11 +379,13 @@ class Scanner3(Scanner):
|
||||
for i, inst in enumerate(self.insts):
|
||||
|
||||
opname = inst.opname
|
||||
argval = inst.argval
|
||||
pattr = inst.argrepr
|
||||
|
||||
t = Token(
|
||||
opname=opname,
|
||||
attr=inst.argval,
|
||||
pattr=inst.argrepr,
|
||||
attr=argval,
|
||||
pattr=pattr,
|
||||
offset=inst.offset,
|
||||
linestart=inst.starts_line,
|
||||
op=inst.opcode,
|
||||
@@ -431,8 +436,8 @@ class Scanner3(Scanner):
|
||||
j = xdis.next_offset(op, self.opc, jump_offset)
|
||||
come_from_opname = self.opname_for_offset(j)
|
||||
|
||||
if opname.startswith("SETUP_"):
|
||||
come_from_type = opname[len("SETUP_") :]
|
||||
if come_from_opname.startswith("SETUP_"):
|
||||
come_from_type = come_from_opname[len("SETUP_") :]
|
||||
come_from_name = "COME_FROM_%s" % come_from_type
|
||||
pass
|
||||
elif inst.offset in self.except_targets:
|
||||
@@ -465,8 +470,6 @@ class Scanner3(Scanner):
|
||||
|
||||
pass
|
||||
|
||||
pattr = inst.argrepr
|
||||
|
||||
if op in self.opc.CONST_OPS:
|
||||
const = argval
|
||||
if iscode(const):
|
||||
@@ -640,6 +643,8 @@ class Scanner3(Scanner):
|
||||
|
||||
last_op_was_break = opname == "BREAK_LOOP"
|
||||
t.kind = opname
|
||||
t.attr = argval
|
||||
t.pattr = pattr
|
||||
new_tokens.append(t)
|
||||
pass
|
||||
|
||||
|
@@ -65,10 +65,12 @@ class Scanner37(Scanner37Base):
|
||||
|
||||
for j in range(collection_start, i):
|
||||
if tokens[j].kind not in (
|
||||
"LOAD_CODE",
|
||||
"LOAD_CONST",
|
||||
"LOAD_FAST",
|
||||
"LOAD_GLOBAL",
|
||||
"LOAD_NAME",
|
||||
"LOAD_STR",
|
||||
):
|
||||
return next_tokens + [t]
|
||||
|
||||
|
@@ -227,7 +227,7 @@ class NonterminalActions:
|
||||
self.indent_more(INDENT_PER_LEVEL)
|
||||
sep = ""
|
||||
if is_dict:
|
||||
keys = flat_elems[-1].pattr
|
||||
keys = flat_elems[-1].attr
|
||||
assert isinstance(keys, tuple)
|
||||
assert len(keys) == len(flat_elems) - 1
|
||||
for i, elem in enumerate(flat_elems[:-1]):
|
||||
|
Reference in New Issue
Block a user