3.6 MAKE_FUNCTION workarounds

Still wrong, but points to diretions for improvements
This commit is contained in:
rocky
2018-02-26 09:06:02 -05:00
parent 31de0d2af5
commit 5c2d0484e5
4 changed files with 41 additions and 15 deletions

Binary file not shown.

View File

@@ -0,0 +1,3 @@
# From 3.6 base64.py. Bug was handling *, and keyword args
def a85decode(b, *, foldspaces=False, adobe=False, ignorechars=b' \t\n\r\v'):
return

View File

@@ -217,6 +217,7 @@ def main(in_base, out_base, files, codes, outfile=None,
sys.stdout.write("\n")
sys.stderr.write("\n# file %s\n# %s\n" % (infile, e))
failed_files += 1
tot_files += 1
except KeyboardInterrupt:
if outfile:
outstream.close()

View File

@@ -619,12 +619,34 @@ def make_function3(self, node, is_lambda, nested=1, codeNode=None):
ends_in_comma = False
break
elif self.version >= 3.6:
d = node[1]
if d == 'expr':
d = d[0]
assert d == 'dict'
defaults = [self.traverse(n, indent='') for n in d[:-2]]
names = eval(self.traverse(d[-2]))
# argc = node[-1].attr
# co = node[-3].attr
# argcount = co.co_argcount
# kwonlyargcount = co.co_kwonlyargcount
free_tup = annotate_dict = kw_dict = default_tup = None
index = 0
# FIXME: this is woefully wrong
if argc & 8:
free_tup = node[index]
index += 1
if argc & 4:
kw_dict = node[1]
index += 1
if argc & 2:
kw_dict = node[index]
index += 1
if argc & 1:
kw_dict = node[index]
if kw_dict == 'expr':
kw_dict = kw_dict[0]
# FIXME: handle free_tup, annotatate_dict, and default_tup
if kw_dict:
assert kw_dict == 'dict'
defaults = [self.traverse(n, indent='') for n in kw_dict[:-2]]
names = eval(self.traverse(kw_dict[-2]))
assert len(defaults) == len(names)
sep = ''
# FIXME: possibly handle line breaks