You've already forked python-uncompyle6
mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2025-08-03 08:49:51 +08:00
3.3-3.4 pos kwargs ordering
This commit is contained in:
BIN
test/bytecode_3.3_run/04_def_annotate.pyc
Normal file
BIN
test/bytecode_3.3_run/04_def_annotate.pyc
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -25,9 +25,8 @@ def test7(*varargs: int, **kwargs):
|
|||||||
def test8(x=55, *varargs: int, **kwargs) -> list:
|
def test8(x=55, *varargs: int, **kwargs) -> list:
|
||||||
return (x, varargs, kwargs)
|
return (x, varargs, kwargs)
|
||||||
|
|
||||||
#def test9(x=55, *varargs: int, y=5, **kwargs):
|
def test9(arg_1=55, *varargs: int, y=5, **kwargs):
|
||||||
# return x, varargs, int, y, kwargs
|
return x, varargs, int, y, kwargs
|
||||||
|
|
||||||
|
|
||||||
def test10(args_1, b: 'annotating b', c: int) -> float:
|
def test10(args_1, b: 'annotating b', c: int) -> float:
|
||||||
return 5.4
|
return 5.4
|
||||||
@@ -75,6 +74,8 @@ def ann2(args_1, b: int = 5, **kwargs: float) -> float:
|
|||||||
assert test1(1, 5) == (1, 5, 4, {})
|
assert test1(1, 5) == (1, 5, 4, {})
|
||||||
assert test1(1, 5, 6, foo='bar') == (1, 5, 6, {'foo': 'bar'})
|
assert test1(1, 5, 6, foo='bar') == (1, 5, 6, {'foo': 'bar'})
|
||||||
assert test2(2, 3, 4) == (2, 3, 4, 4, (), {})
|
assert test2(2, 3, 4) == (2, 3, 4, 4, (), {})
|
||||||
|
assert test3(10, foo='bar') == 5.4
|
||||||
|
assert test4(9.5, 7, 6, 4, bar='baz') == 5.4
|
||||||
### FIXME: fill in...
|
### FIXME: fill in...
|
||||||
assert test6(1.2, 3) == (1.2, 3, None)
|
assert test6(1.2, 3) == (1.2, 3, None)
|
||||||
assert test6(2.3, 4, 5) == (2.3, 4, 5)
|
assert test6(2.3, 4, 5) == (2.3, 4, 5)
|
||||||
|
@@ -1064,12 +1064,18 @@ 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:
|
||||||
|
# 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%sannotate_tuple LOAD_CONST LOAD_CONST EXTENDED_ARG %s' %
|
rule = ('mkfunc_annotate ::= %s%s%sannotate_tuple LOAD_CONST LOAD_CONST EXTENDED_ARG %s' %
|
||||||
(('pos_arg ' * (args_pos), ('kwargs ' * args_kw),
|
( 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)
|
||||||
rule = ('mkfunc_annotate ::= %s%s%sannotate_tuple LOAD_CONST LOAD_CONST EXTENDED_ARG %s' %
|
rule = ('mkfunc_annotate ::= %s%s%sannotate_tuple LOAD_CONST LOAD_CONST EXTENDED_ARG %s' %
|
||||||
(('pos_arg ' * (args_pos)), ('kwargs ' * args_kw),
|
( pos_kw_tuple[0], pos_kw_tuple[1],
|
||||||
('annotate_arg ' * (annotate_args-1)), opname))
|
('annotate_arg ' * (annotate_args-1)), opname))
|
||||||
else:
|
else:
|
||||||
# See above comment about use of EXTENDED_ARG
|
# See above comment about use of EXTENDED_ARG
|
||||||
|
Reference in New Issue
Block a user