Fix 3.6 MAKE_FUNCTION for kw params...

and remove duplicated attributies in pattr of MAKE_FUNCITON token.
This commit is contained in:
rocky
2018-03-01 07:14:46 -05:00
parent 257c3ca454
commit f7439f506a
5 changed files with 19 additions and 21 deletions

View File

@@ -1,3 +1,8 @@
# 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
# From 3.6 configparser.py. Same problem as above.
_UNSET = object()
def get(self, section, option, *, raw=False, vars=None, fallback=_UNSET):
return

View File

@@ -354,11 +354,6 @@ class Scanner3(Scanner):
attr = []
for flag in self.MAKE_FUNCTION_FLAGS:
bit = flags & 1
if bit:
if pattr:
pattr += ", " + flag
else:
pattr += flag
attr.append(bit)
flags >>= 1
attr = attr[:4] # remove last value: attr[5] == False

View File

@@ -17,7 +17,6 @@
import re, sys
from uncompyle6 import PYTHON3
from xdis.bytecode import op_has_argument
if PYTHON3:
intern = sys.intern

View File

@@ -625,19 +625,22 @@ def make_function3(self, node, is_lambda, nested=1, codeNode=None):
# kwonlyargcount = co.co_kwonlyargcount
free_tup = annotate_dict = kw_dict = default_tup = None
index = 0
# FIXME: this is woefully wrong
if argc & 8:
fn_bits = node[-1].attr
index = -4 # Skip over:
# MAKE_FUNCTION,
# LOAD_CONST qualified name,
# LOAD_CONST code object
if fn_bits[-1]:
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:
index -= 1
if fn_bits[-2]:
annotate_dict = node[index]
index -= 1
if fn_bits[-3]:
kw_dict = node[index]
index -= 1
if fn_bits[-4]:
default_tup = node[index]
if kw_dict == 'expr':
kw_dict = kw_dict[0]
@@ -645,10 +648,6 @@ def make_function3(self, node, is_lambda, nested=1, codeNode=None):
# FIXME: handle free_tup, annotate_dict, and default_tup
if kw_dict:
assert kw_dict == 'dict'
# try:
# assert kw_dict == 'dict'
# except:
# from trepan.api import debug; debug()
defaults = [self.traverse(n, indent='') for n in kw_dict[:-2]]
names = eval(self.traverse(kw_dict[-2]))
assert len(defaults) == len(names)