Skip to content

Commit 090570c

Browse files
committed
3.4-3.5 MAKE_CLOSURE with annotate
Docs lie about annnotation args. Slight adjustment here. More is probably needed.
1 parent 16914fe commit 090570c

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

uncompyle6/parser.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ def error(self, instructions, index):
199199
if instructions[finish].linestart:
200200
break
201201
pass
202-
if start > 0:
202+
if start >= 0:
203203
err_token = instructions[index]
204204
print("Instruction context:")
205205
for i in range(start, finish):

uncompyle6/scanners/scanner3.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -626,10 +626,19 @@ def ingest(self, co, classname=None, code_objects={}, show_asm=None
626626
pos_args, name_pair_args, annotate_args = parse_fn_counts(
627627
inst.argval
628628
)
629+
630+
correct_annotate_args = annotate_args
631+
if opname == "MAKE_CLOSURE" and ((3, 4) <= self.version < (3, 6)) and annotate_args > 0:
632+
# For some reason that I don't understand annotate_args is off by one
633+
# here from what is documented in
634+
# https://docs.python.org/3.4/library/dis.html#opcode-MAKE_CLOSURE
635+
# However in parsing rule, we have already adjusted for the one-fewer annotate arg
636+
correct_annotate_args -= 1
637+
629638
pattr = "%d positional, %d keyword only, %d annotated" % (
630639
pos_args,
631640
name_pair_args,
632-
annotate_args,
641+
correct_annotate_args,
633642
)
634643
if name_pair_args > 0:
635644
# FIXME: this should probably be K_

0 commit comments

Comments
 (0)