3.3-3.4 pos kwargs ordering

This commit is contained in:
rocky
2019-06-08 18:40:50 -04:00
parent 9fe1752359
commit 86fd5dbf7a
6 changed files with 13 additions and 6 deletions

View File

@@ -1064,12 +1064,18 @@ class Python3Parser(PythonParser):
# 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.
# 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' %
(('pos_arg ' * (args_pos), ('kwargs ' * args_kw),
('call ' * (annotate_args-1)), opname)))
( pos_kw_tuple[0], pos_kw_tuple[1],
('call ' * (annotate_args-1)), opname))
self.add_unique_rule(rule, opname, token.attr, customize)
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))
else:
# See above comment about use of EXTENDED_ARG