You've already forked python-uncompyle6
mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2025-08-04 09:22:40 +08:00
Python 3.x bug in handling var number of args
This commit is contained in:
BIN
test/bytecode_3.5/02_fn_varargs.pyc
Normal file
BIN
test/bytecode_3.5/02_fn_varargs.pyc
Normal file
Binary file not shown.
5
test/simple_source/bug35/02_fn_varargs.py
Normal file
5
test/simple_source/bug35/02_fn_varargs.py
Normal file
@@ -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
|
@@ -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
|
||||
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 not (4 & code.co_flags):
|
||||
if argc > 0:
|
||||
self.write(", *, ")
|
||||
else:
|
||||
self.write("*, ")
|
||||
pass
|
||||
else:
|
||||
self.write(", ")
|
||||
|
||||
for n in node:
|
||||
if n == 'pos_arg':
|
||||
continue
|
||||
|
Reference in New Issue
Block a user