Fix issue in commas in function signatures

This commit is contained in:
x0ret
2019-06-10 01:42:16 +04:30
parent 719d2d7232
commit a54fba7993

View File

@@ -694,6 +694,9 @@ def make_function3(self, node, is_lambda, nested=1, code_node=None):
else: else:
kw_pairs = 0 kw_pairs = 0
i = len(paramnames) - len(defparams)
no_paramnames = len(paramnames[:i]) == 0
# build parameters # build parameters
params = [] params = []
if defparams: if defparams:
@@ -750,17 +753,22 @@ def make_function3(self, node, is_lambda, nested=1, code_node=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 = True ends_in_comma = False
if kwonlyargcount > 0: if kwonlyargcount > 0:
if not (4 & code.co_flags): if no_paramnames:
if argc > 0: if not (4 & code.co_flags):
self.write(", *, ") if argc > 0:
self.write(", *, ")
else:
self.write("*, ")
pass
else: else:
self.write("*, ") self.write(", ")
pass ends_in_comma = True
else: else:
self.write(", ") if argc > 0:
ends_in_comma = True 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?
@@ -855,8 +863,9 @@ def make_function3(self, node, is_lambda, nested=1, code_node=None):
ends_in_comma = False ends_in_comma = False
pass pass
elif argc > 0: else:
self.write(', ') if argc == 0:
ends_in_comma = True
if code_has_star_star_arg(code): if code_has_star_star_arg(code):
if not ends_in_comma: if not ends_in_comma: