3.3+ bug in handling single kwarg after *

Towards fixing issue #110
This commit is contained in:
rocky
2017-04-22 04:18:43 -04:00
parent 810649799c
commit e5008693a1
3 changed files with 8 additions and 2 deletions

View File

@@ -1,3 +1,6 @@
# From Python 3.3.6 hmac.py # From Python 3.3.6 hmac.py
# Problem was getting wrong placement of positional args # Problem was getting wrong placement of positional args
digest_cons = lambda d=b'': 5 digest_cons = lambda d=b'': 5
# Handle single kwarg
lambda *, d=0: None

View File

@@ -697,7 +697,10 @@ class Python3Parser(PythonParser):
rule_pat = ("genexpr ::= %sload_genexpr %%s%s expr " rule_pat = ("genexpr ::= %sload_genexpr %%s%s expr "
"GET_ITER CALL_FUNCTION_1" % ('pos_arg '* args_pos, opname)) "GET_ITER CALL_FUNCTION_1" % ('pos_arg '* args_pos, opname))
self.add_make_function_rule(rule_pat, opname, token.attr, customize) 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) self.add_make_function_rule(rule_pat, opname, token.attr, customize)
rule_pat = ("listcomp ::= %sLOAD_LISTCOMP %%s%s expr " rule_pat = ("listcomp ::= %sLOAD_LISTCOMP %%s%s expr "
"GET_ITER CALL_FUNCTION_1" % ('expr ' * args_pos, opname)) "GET_ITER CALL_FUNCTION_1" % ('expr ' * args_pos, opname))

View File

@@ -567,7 +567,7 @@ def make_function3(self, node, isLambda, nested=1, codeNode=None):
for n in node: for n in node:
if n == 'pos_arg': if n == 'pos_arg':
continue continue
elif self.version >= 3.4 and n.type != 'kwargs': elif self.version >= 3.4 and not (n.type in ('kwargs', 'kwarg')):
continue continue
else: else:
self.preorder(n) self.preorder(n)