Skip to content

Commit 2886d2b

Browse files
committed
Track important changes to xdis
Annotation counts have changed. EXTENDED_ARGS adjustment in instructions have been corrected.
1 parent 8348d86 commit 2886d2b

File tree

3 files changed

+17
-29
lines changed

3 files changed

+17
-29
lines changed

uncompyle6/parsers/parse33.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,6 @@ def p_33on(self, args):
1616
stmt ::= genexpr_func
1717
"""
1818

19-
def p_33_function_def(self, args):
20-
"""
21-
annotate_pair ::= LOAD_NAME LOAD_CONST
22-
23-
"""
24-
2519
def customize_grammar_rules(self, tokens, customize):
2620
self.remove_rules(
2721
"""

uncompyle6/scanners/scanner3.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2015-2019, 2021-2023 by Rocky Bernstein
1+
# Copyright (c) 2015-2019, 2021-2024 by Rocky Bernstein
22
# Copyright (c) 2005 by Dan Pascu <[email protected]>
33
# Copyright (c) 2000-2002 by hartmut Goebel <[email protected]>
44
#
@@ -482,7 +482,6 @@ def ingest(
482482

483483
last_op_was_break = False
484484
new_tokens = []
485-
operand_value = 0
486485

487486
for i, inst in enumerate(self.insts):
488487
opname = inst.opname
@@ -534,11 +533,9 @@ def ingest(
534533
op = inst.opcode
535534

536535
if opname == "EXTENDED_ARG":
537-
if i + 1 < n:
538-
operand_value = argval << 16
539-
continue
540-
else:
541-
operand_value = 0
536+
# EXTEND_ARG adjustments to the operand value should have
537+
# already been accounted for in xdis instruction creation.
538+
continue
542539

543540
if inst.offset in jump_targets:
544541
jump_idx = 0
@@ -645,7 +642,7 @@ def ingest(
645642
attr = attr[:4] # remove last value: attr[5] == False
646643
else:
647644
pos_args, name_pair_args, annotate_args = parse_fn_counts_30_35(
648-
inst.argval + operand_value
645+
inst.argval
649646
)
650647

651648
pattr = f"{pos_args} positional, {name_pair_args} keyword only, {annotate_args} annotated"

uncompyle6/semantics/make_function3.py

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2015-2021 by Rocky Bernstein
1+
# Copyright (c) 2015-2021, 2024 by Rocky Bernstein
22
#
33
# This program is free software: you can redistribute it and/or modify
44
# it under the terms of the GNU General Public License as published by
@@ -16,18 +16,18 @@
1616
All the crazy things we have to do to handle Python functions in 3.0-3.5 or so.
1717
The saga of changes before and after is in other files.
1818
"""
19-
from xdis import iscode, code_has_star_arg, code_has_star_star_arg, CO_GENERATOR
20-
from uncompyle6.scanner import Code
21-
from uncompyle6.parsers.treenode import SyntaxTree
22-
from uncompyle6.semantics.parser_error import ParserError
19+
from xdis import CO_GENERATOR, code_has_star_arg, code_has_star_star_arg, iscode
20+
2321
from uncompyle6.parser import ParserError as ParserError2
22+
from uncompyle6.parsers.treenode import SyntaxTree
23+
from uncompyle6.scanner import Code
2424
from uncompyle6.semantics.helper import (
25-
print_docstring,
2625
find_all_globals,
2726
find_globals_and_nonlocals,
2827
find_none,
28+
print_docstring,
2929
)
30-
30+
from uncompyle6.semantics.parser_error import ParserError
3131
from uncompyle6.show import maybe_show_tree_param_default
3232

3333
# FIXME: DRY the below code...
@@ -42,8 +42,8 @@ def make_function3_annotate(
4242

4343
def build_param(ast, name, default):
4444
"""build parameters:
45-
- handle defaults
46-
- handle format tuple parameters
45+
- handle defaults
46+
- handle format tuple parameters
4747
"""
4848
if default:
4949
value = self.traverse(default, indent="")
@@ -300,7 +300,7 @@ def build_param(ast, name, default):
300300

301301
def make_function3(self, node, is_lambda, nested=1, code_node=None):
302302
"""Dump function definition, doc string, and function body in
303-
Python version 3.0 and above
303+
Python version 3.0 and above
304304
"""
305305

306306
# For Python 3.3, the evaluation stack in MAKE_FUNCTION is:
@@ -333,8 +333,8 @@ def make_function3(self, node, is_lambda, nested=1, code_node=None):
333333

334334
def build_param(ast, name, default, annotation=None):
335335
"""build parameters:
336-
- handle defaults
337-
- handle format tuple parameters
336+
- handle defaults
337+
- handle format tuple parameters
338338
"""
339339
value = self.traverse(default, indent="")
340340
maybe_show_tree_param_default(self.showast, name, value)
@@ -419,7 +419,6 @@ def build_param(ast, name, default, annotation=None):
419419
pass
420420

421421
if len(node) > 2 and (have_kwargs or node[lc_index].kind != "load_closure"):
422-
423422
# Find the index in "node" where the first default
424423
# parameter value is located. Note this is in contrast to
425424
# key-word arguments, pairs of (name, value), which appear after "*".
@@ -492,8 +491,6 @@ def build_param(ast, name, default, annotation=None):
492491
self.ERROR = p
493492
return
494493

495-
kw_pairs = 0
496-
497494
i = len(paramnames) - len(defparams)
498495

499496
# build parameters

0 commit comments

Comments
 (0)