Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions uncompyle6/scanner.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,10 @@ def bound_collection_from_tokens(self, tokens, t, i, collection_type):
for j in range(collection_start, i):
if tokens[j] == "LOAD_CONST":
opname = "ADD_VALUE"
op_type = "const"
else:
opname = "ADD_VALUE_VAR"
op_type = "name"
new_tokens.append(
Token(
opname=opname,
Expand All @@ -196,6 +198,7 @@ def bound_collection_from_tokens(self, tokens, t, i, collection_type):
linestart=tokens[j].linestart,
opc=self.opc,
has_extended_arg=False,
optype=op_type
)
)
new_tokens.append(
Expand All @@ -208,6 +211,7 @@ def bound_collection_from_tokens(self, tokens, t, i, collection_type):
linestart=t.linestart,
opc=t.opc,
has_extended_arg=False,
optype="vargs",
)
)
return new_tokens
Expand Down
16 changes: 13 additions & 3 deletions uncompyle6/scanners/scanner2.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2015-2024 by Rocky Bernstein
# Copyright (c) 2015-2025 by Rocky Bernstein
# Copyright (c) 2005 by Dan Pascu <dan@windowmaker.org>
# Copyright (c) 2000-2002 by hartmut Goebel <h.goebel@crazy-compilers.com>
#
Expand Down Expand Up @@ -39,7 +39,7 @@
from sys import intern

from xdis import code2num, instruction_size, iscode, op_has_argument
from xdis.bytecode import _get_const_info
from xdis.bytecode import _get_const_info, get_optype

from uncompyle6.scanner import Scanner, Token

Expand Down Expand Up @@ -304,6 +304,7 @@ def ingest(self, co, classname=None, code_objects={}, show_asm=None):

op = self.code[offset]
op_name = self.op_name(op)
op_type = get_optype(op, self.opc)

oparg = None
pattr = None
Expand Down Expand Up @@ -470,7 +471,15 @@ def ingest(self, co, classname=None, code_objects={}, show_asm=None):
if offset not in replace:
new_tokens.append(
Token(
op_name, oparg, pattr, offset, linestart, op, has_arg, self.opc
op_name,
oparg,
pattr,
offset,
linestart,
op,
has_arg,
self.opc,
optype=op_type,
)
)
else:
Expand All @@ -484,6 +493,7 @@ def ingest(self, co, classname=None, code_objects={}, show_asm=None):
op,
has_arg,
self.opc,
optype=op_type,
)
)
pass
Expand Down
4 changes: 2 additions & 2 deletions uncompyle6/semantics/n_actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,8 +275,8 @@ def n_const_list(self, node: SyntaxTree):
if elem == "ADD_VALUE":
if elem.optype in ("local", "name"):
value = elem.attr
elif elem.optype == "const" and not isinstance(elem.attr, str):
value = elem.attr
elif elem.optype == "const":
value = elem.pattr
else:
value = "%s" % repr(elem.attr)
else:
Expand Down