Bug in detecting 3.3 default value in lambda

This commit is contained in:
rocky
2016-11-10 23:15:06 -05:00
parent 6fb879d0d8
commit 0f536b18fa
6 changed files with 13 additions and 4 deletions

Binary file not shown.

Binary file not shown.

View File

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

View File

@@ -0,0 +1,6 @@
# Bug from Python 3.3 codecs.py
# Bug is in 3.3 handling of this complicated parameter list
def __new__(cls, encode, decode, streamreader=None, streamwriter=None,
incrementalencoder=None, incrementaldecoder=None, name=None,
*, _is_text_encoding=None):
return

View File

@@ -1609,16 +1609,16 @@ class FragmentsWalker(pysource.SourceWalker, object):
args_node = node[-1]
if isinstance(args_node.attr, tuple):
if self.version == 3.3:
if self.version <= 3.3 and len(node) > 2 and node[-3] != 'LOAD_LAMBDA':
# positional args are after kwargs
defparams = node[1:args_node.attr[0]+1]
else:
# positional args are before kwargs
defparams = node[:args_node.attr[0]]
pos_aargs, kw_args, annotate_args = args_node.attr
pos_args, kw_args, annotate_argc = args_node.attr
else:
defparams = node[:args_node.attr]
kw_args, annotate_args = (0, 0)
kw_args, annotate_argc = (0, 0)
pass
if self.version > 3.0 and isLambda and iscode(node[-3].attr):

View File

@@ -395,7 +395,7 @@ def make_function3(self, node, isLambda, nested=1, codeNode=None):
args_node = node[-1]
if isinstance(args_node.attr, tuple):
if self.version <= 3.3:
if self.version <= 3.3 and len(node) > 2 and node[-3] != 'LOAD_LAMBDA':
# positional args are after kwargs
defparams = node[1:args_node.attr[0]+1]
else: