Start handling 3.6 CALL_FUNCTION_KW

This commit is contained in:
rocky
2017-12-14 08:36:12 -05:00
parent 4cd4ad22b6
commit a1082ebae9
2 changed files with 39 additions and 9 deletions

View File

@@ -1787,6 +1787,11 @@ class SourceWalker(GenericASTTraversal, object):
def print_super_classes3(self, node):
n = len(node)-1
if node.kind != 'expr':
kwargs = None
# 3.6+ starts having this
if node[n].kind.startswith('CALL_FUNCTION_KW'):
kwargs = node[n-1].attr
assert isinstance(kwargs, tuple)
assert node[n].kind.startswith('CALL_FUNCTION')
for i in range(n-2, 0, -1):
if not node[i].kind in ['expr', 'LOAD_CLASSNAME']:
@@ -1798,11 +1803,20 @@ class SourceWalker(GenericASTTraversal, object):
line_separator = ', '
sep = ''
self.write('(')
j = 0
i += 2
while i < n:
if kwargs:
l = n - 1
else:
l = n
while i < l:
value = self.traverse(node[i])
i += 1
self.write(sep, value)
# 3.6+ may have this
if kwargs:
self.write("=%s" % kwargs[j])
j += 1
sep = line_separator
pass
pass