Another 3.6 lambda parsing bug

This commit is contained in:
rocky
2018-03-19 09:09:59 -04:00
parent 5c662b334e
commit 9e05750537
2 changed files with 19 additions and 6 deletions

View File

@@ -1,4 +1,11 @@
# From Python 3.6 hmac.py
# needed to change mklamba rule
# needed to change mklambda rule
def __init__(self, msg = None, digestmod = None):
self.digest_cons = lambda d='': digestmod.new(d)
# From Python 3.6 functools.py
# Bug was handling lambda for MAKE_FUNCTION_8 (closure)
# vs to MAKE_FUNCTION_9 (pos_args + closure)
def bug():
def register(cls, func=None):
return lambda f: register(cls, f)

View File

@@ -887,11 +887,17 @@ class Python3Parser(PythonParser):
args_pos, args_kw, annotate_args, closure = token.attr
stack_count = args_pos + args_kw + annotate_args
if closure:
rule = ('mklambda ::= %s%s%s%s' %
('expr ' * stack_count,
'load_closure ' * closure,
'BUILD_TUPLE_1 LOAD_LAMBDA LOAD_CONST ',
opname))
if args_pos:
rule = ('mklambda ::= %s%s%s%s' %
('expr ' * stack_count,
'load_closure ' * closure,
'BUILD_TUPLE_1 LOAD_LAMBDA LOAD_CONST ',
opname))
else:
rule = ('mklambda ::= %s%s%s' %
('load_closure ' * closure,
'BUILD_TUPLE_2 LOAD_LAMBDA LOAD_CONST ',
opname))
self.add_unique_rule(rule, opname, token.attr, customize)
rule = ('mkfunc ::= %s%s%s%s' %