You've already forked python-uncompyle6
mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2025-08-04 09:14:10 +08:00
LOAD_CONST->LOAD_STR bugs and 3.4 kwargsonly
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1064,19 +1064,13 @@ class Python3Parser(PythonParser):
|
|||||||
# Normally we remove EXTENDED_ARG from the opcodes, but in the case of
|
# Normally we remove EXTENDED_ARG from the opcodes, but in the case of
|
||||||
# annotated functions can use the EXTENDED_ARG tuple to signal we have an annotated function.
|
# annotated functions can use the EXTENDED_ARG tuple to signal we have an annotated function.
|
||||||
# Yes this is a little hacky
|
# Yes this is a little hacky
|
||||||
if self.version < 3.5:
|
if self.version == 3.3:
|
||||||
# 3.3 and 3.4 put kwargs before pos_arg
|
# 3.3 puts kwargs before pos_arg
|
||||||
pos_kw_tuple = (('kwargs ' * args_kw), ('pos_arg ' * (args_pos)))
|
pos_kw_tuple = (('kwargs ' * args_kw), ('pos_arg ' * (args_pos)))
|
||||||
else:
|
else:
|
||||||
# 3.5 puts pos_arg before kwargs
|
# 3.4 and 3.5puts pos_arg before kwargs
|
||||||
pos_kw_tuple = (('pos_arg ' * (args_pos), ('kwargs ' * args_kw)))
|
pos_kw_tuple = (('pos_arg ' * (args_pos), ('kwargs ' * args_kw)))
|
||||||
if self.version < 3.5:
|
rule = ('mkfunc_annotate ::= %s%s%sannotate_tuple LOAD_CONST LOAD_STR EXTENDED_ARG %s' %
|
||||||
# 3.3 and 3.4 put kwargs before pos_arg
|
|
||||||
pos_kw_tuple = (('kwargs ' * args_kw), ('pos_arg ' * (args_pos)))
|
|
||||||
else:
|
|
||||||
# 3.5 puts pos_arg before kwargs
|
|
||||||
pos_kw_tuple = (('pos_arg ' * (args_pos), ('kwargs ' * args_kw)))
|
|
||||||
rule = ('mkfunc_annotate ::= %s%s%s%sannotate_tuple LOAD_CONST LOAD_STR EXTENDED_ARG %s' %
|
|
||||||
( pos_kw_tuple[0], pos_kw_tuple[1],
|
( pos_kw_tuple[0], pos_kw_tuple[1],
|
||||||
('call ' * (annotate_args-1)), opname))
|
('call ' * (annotate_args-1)), opname))
|
||||||
self.add_unique_rule(rule, opname, token.attr, customize)
|
self.add_unique_rule(rule, opname, token.attr, customize)
|
||||||
|
@@ -88,7 +88,7 @@ def customize_for_version3(self, version):
|
|||||||
code_node = build_class[1][0]
|
code_node = build_class[1][0]
|
||||||
class_name = code_node.attr.co_name
|
class_name = code_node.attr.co_name
|
||||||
else:
|
else:
|
||||||
class_name = node[1][0].pattr
|
class_name = node[1][0].attr
|
||||||
build_class = node[0]
|
build_class = node[0]
|
||||||
|
|
||||||
assert 'mkfunc' == build_class[1]
|
assert 'mkfunc' == build_class[1]
|
||||||
|
@@ -216,7 +216,7 @@ def make_function3_annotate(self, node, is_lambda, nested=1,
|
|||||||
if (line_number != self.line_number):
|
if (line_number != self.line_number):
|
||||||
self.write("\n" + indent)
|
self.write("\n" + indent)
|
||||||
line_number = self.line_number
|
line_number = self.line_number
|
||||||
kn = n[0].pattr
|
kn = n[0].attr
|
||||||
if kn in annotate_tuple[0].attr:
|
if kn in annotate_tuple[0].attr:
|
||||||
p = annotate_tuple[0].attr.index(star_arg) + pos_args + kw_args
|
p = annotate_tuple[0].attr.index(star_arg) + pos_args + kw_args
|
||||||
self.write('%s: ' % kn)
|
self.write('%s: ' % kn)
|
||||||
|
@@ -1436,7 +1436,7 @@ class SourceWalker(GenericASTTraversal, object):
|
|||||||
n = len(node) - 1
|
n = len(node) - 1
|
||||||
if node.kind != 'expr':
|
if node.kind != 'expr':
|
||||||
if node == 'kwarg':
|
if node == 'kwarg':
|
||||||
self.template_engine(('(%[0]{pattr}=%c)', 1), node)
|
self.template_engine(('(%[0]{attr}=%c)', 1), node)
|
||||||
return
|
return
|
||||||
|
|
||||||
kwargs = None
|
kwargs = None
|
||||||
|
Reference in New Issue
Block a user