diff --git a/test/bytecode_3.5/02_fn_varargs.pyc b/test/bytecode_3.5/02_fn_varargs.pyc new file mode 100644 index 00000000..9a65c87e Binary files /dev/null and b/test/bytecode_3.5/02_fn_varargs.pyc differ diff --git a/test/simple_source/bug35/02_fn_varargs.py b/test/simple_source/bug35/02_fn_varargs.py new file mode 100644 index 00000000..42d568bf --- /dev/null +++ b/test/simple_source/bug35/02_fn_varargs.py @@ -0,0 +1,5 @@ +# From python 3.4 pstats.py +# Bug was not adding *, since *args covers that. And getting stream=None +# without * +def __init__(self, *args, stream=None): + pass diff --git a/uncompyle6/semantics/pysource.py b/uncompyle6/semantics/pysource.py index a1baeaa1..def3a00e 100644 --- a/uncompyle6/semantics/pysource.py +++ b/uncompyle6/semantics/pysource.py @@ -2010,8 +2010,12 @@ class SourceWalker(GenericASTTraversal, object): params.reverse() # back to correct order if 4 & code.co_flags: # flag 2 -> variable number of args - params.append('*%s' % code.co_varnames[argc]) + if self.version > 3.0: + params.append('*%s' % code.co_varnames[argc + args_node.attr[1]]) + else: + params.append('*%s' % code.co_varnames[argc]) argc += 1 + if 8 & code.co_flags: # flag 3 -> keyword args params.append('**%s' % code.co_varnames[argc]) argc += 1 @@ -2025,10 +2029,15 @@ class SourceWalker(GenericASTTraversal, object): # self.println(indent, '#flags:\t', int(code.co_flags)) if kw_args > 0: - if argc > 0: - self.write(", *, ") + if not (4 & code.co_flags): + if argc > 0: + self.write(", *, ") + else: + self.write("*, ") + pass else: - self.write("*, ") + self.write(", ") + for n in node: if n == 'pos_arg': continue