From e5008693a13e9e6b3493599594efcad6d22afb6f Mon Sep 17 00:00:00 2001 From: rocky Date: Sat, 22 Apr 2017 04:18:43 -0400 Subject: [PATCH] 3.3+ bug in handling single kwarg after * Towards fixing issue #110 --- test/simple_source/bug33/02_pos_args.py | 3 +++ uncompyle6/parsers/parse3.py | 5 ++++- uncompyle6/semantics/make_function.py | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/test/simple_source/bug33/02_pos_args.py b/test/simple_source/bug33/02_pos_args.py index 4eb8cc0a..d3a6ad52 100644 --- a/test/simple_source/bug33/02_pos_args.py +++ b/test/simple_source/bug33/02_pos_args.py @@ -1,3 +1,6 @@ # From Python 3.3.6 hmac.py # Problem was getting wrong placement of positional args digest_cons = lambda d=b'': 5 + +# Handle single kwarg +lambda *, d=0: None diff --git a/uncompyle6/parsers/parse3.py b/uncompyle6/parsers/parse3.py index dc534c57..a4ac47bf 100644 --- a/uncompyle6/parsers/parse3.py +++ b/uncompyle6/parsers/parse3.py @@ -697,7 +697,10 @@ class Python3Parser(PythonParser): rule_pat = ("genexpr ::= %sload_genexpr %%s%s expr " "GET_ITER CALL_FUNCTION_1" % ('pos_arg '* args_pos, opname)) self.add_make_function_rule(rule_pat, opname, token.attr, customize) - rule_pat = ('mklambda ::= %sLOAD_LAMBDA %%s%s' % ('pos_arg '* args_pos, opname)) + rule_pat = ('mklambda ::= %s%sLOAD_LAMBDA %%s%s' % + (('pos_arg '* args_pos), + ('kwarg '* args_kw), + opname)) self.add_make_function_rule(rule_pat, opname, token.attr, customize) rule_pat = ("listcomp ::= %sLOAD_LISTCOMP %%s%s expr " "GET_ITER CALL_FUNCTION_1" % ('expr ' * args_pos, opname)) diff --git a/uncompyle6/semantics/make_function.py b/uncompyle6/semantics/make_function.py index 6b3ea5ad..1ccefc83 100644 --- a/uncompyle6/semantics/make_function.py +++ b/uncompyle6/semantics/make_function.py @@ -567,7 +567,7 @@ def make_function3(self, node, isLambda, nested=1, codeNode=None): for n in node: if n == 'pos_arg': continue - elif self.version >= 3.4 and n.type != 'kwargs': + elif self.version >= 3.4 and not (n.type in ('kwargs', 'kwarg')): continue else: self.preorder(n)