You've already forked python-uncompyle6
mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2025-08-04 01:09:52 +08:00
3.x bug in adding extra , in **kargs
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
# Copyright (c) 2015-2017 by Rocky Bernstein
|
# Copyright (c) 2015-2018 by Rocky Bernstein
|
||||||
# Copyright (c) 2000-2002 by hartmut Goebel <h.goebel@crazy-compilers.com>
|
# Copyright (c) 2000-2002 by hartmut Goebel <h.goebel@crazy-compilers.com>
|
||||||
"""
|
"""
|
||||||
All the crazy things we have to do to handle Python functions
|
All the crazy things we have to do to handle Python functions
|
||||||
@@ -147,6 +147,7 @@ def make_function3_annotate(self, node, is_lambda, nested=1,
|
|||||||
# else:
|
# else:
|
||||||
# self.write(': %s' % value)
|
# self.write(': %s' % value)
|
||||||
|
|
||||||
|
|
||||||
suffix = ', ' if i > 0 else ''
|
suffix = ', ' if i > 0 else ''
|
||||||
for n in node:
|
for n in node:
|
||||||
if n == 'pos_arg':
|
if n == 'pos_arg':
|
||||||
@@ -507,7 +508,6 @@ def make_function3(self, node, is_lambda, nested=1, codeNode=None):
|
|||||||
# FIXME: handle kw, annotate and closure
|
# FIXME: handle kw, annotate and closure
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
if lambda_index and is_lambda and iscode(node[lambda_index].attr):
|
if lambda_index and is_lambda and iscode(node[lambda_index].attr):
|
||||||
assert node[lambda_index].kind == 'LOAD_LAMBDA'
|
assert node[lambda_index].kind == 'LOAD_LAMBDA'
|
||||||
code = node[lambda_index].attr
|
code = node[lambda_index].attr
|
||||||
@@ -575,6 +575,7 @@ def make_function3(self, node, is_lambda, nested=1, codeNode=None):
|
|||||||
self.write("(", ", ".join(params))
|
self.write("(", ", ".join(params))
|
||||||
# self.println(indent, '#flags:\t', int(code.co_flags))
|
# self.println(indent, '#flags:\t', int(code.co_flags))
|
||||||
|
|
||||||
|
ends_in_comma = False
|
||||||
if kw_args > 0:
|
if kw_args > 0:
|
||||||
if not (4 & code.co_flags):
|
if not (4 & code.co_flags):
|
||||||
if argc > 0:
|
if argc > 0:
|
||||||
@@ -584,6 +585,7 @@ def make_function3(self, node, is_lambda, nested=1, codeNode=None):
|
|||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
self.write(", ")
|
self.write(", ")
|
||||||
|
ends_in_comma = True
|
||||||
|
|
||||||
# FIXME: this is not correct for 3.5. or 3.6 (which works different)
|
# FIXME: this is not correct for 3.5. or 3.6 (which works different)
|
||||||
# and 3.7?
|
# and 3.7?
|
||||||
@@ -597,7 +599,10 @@ def make_function3(self, node, is_lambda, nested=1, codeNode=None):
|
|||||||
self.preorder(n[1])
|
self.preorder(n[1])
|
||||||
if i < last:
|
if i < last:
|
||||||
self.write(', ')
|
self.write(', ')
|
||||||
|
ends_in_comma = True
|
||||||
pass
|
pass
|
||||||
|
else:
|
||||||
|
ends_in_comma = False
|
||||||
pass
|
pass
|
||||||
i += 1
|
i += 1
|
||||||
pass
|
pass
|
||||||
@@ -611,6 +616,7 @@ def make_function3(self, node, is_lambda, nested=1, codeNode=None):
|
|||||||
continue
|
continue
|
||||||
else:
|
else:
|
||||||
self.preorder(n)
|
self.preorder(n)
|
||||||
|
ends_in_comma = False
|
||||||
break
|
break
|
||||||
elif self.version >= 3.6:
|
elif self.version >= 3.6:
|
||||||
d = node[1]
|
d = node[1]
|
||||||
@@ -626,12 +632,13 @@ def make_function3(self, node, is_lambda, nested=1, codeNode=None):
|
|||||||
self.write(sep)
|
self.write(sep)
|
||||||
self.write("%s=%s" % (n, defaults[i]))
|
self.write("%s=%s" % (n, defaults[i]))
|
||||||
sep = ', '
|
sep = ', '
|
||||||
|
ends_in_comma = True
|
||||||
pass
|
pass
|
||||||
pass
|
pass
|
||||||
pass
|
pass
|
||||||
|
|
||||||
if code_has_star_star_arg(code):
|
if code_has_star_star_arg(code):
|
||||||
if argc > 0:
|
if argc > 0 and not ends_in_comma:
|
||||||
self.write(', ')
|
self.write(', ')
|
||||||
self.write('**%s' % code.co_varnames[argc + kw_pairs])
|
self.write('**%s' % code.co_varnames[argc + kw_pairs])
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user