You've already forked python-uncompyle6
mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2025-08-03 00:45:53 +08:00
Fix Python 3.x named param and kwargs bug
This commit is contained in:
BIN
test/bytecode_3.3/02_named_and_kwargs.pyc
Normal file
BIN
test/bytecode_3.3/02_named_and_kwargs.pyc
Normal file
Binary file not shown.
4
test/simple_source/bug33/02_named_and_kwargs.py
Normal file
4
test/simple_source/bug33/02_named_and_kwargs.py
Normal file
@@ -0,0 +1,4 @@
|
||||
# Python 3.6 subprocess.py bug
|
||||
# Bug is getting params correct: timeout before **kwargs
|
||||
def call(*popenargs, timeout=None, **kwargs):
|
||||
return
|
@@ -392,9 +392,15 @@ class Scanner2(scan.Scanner):
|
||||
stmts.remove(s)
|
||||
continue
|
||||
elif code[s] == self.opc.POP_TOP:
|
||||
# The POP_TOP in:
|
||||
# ROT_TWO, POP_TOP or
|
||||
# JUMP_IF_{FALSE,TRUE}, POP_TOP
|
||||
# is part of the previous instruction and not the
|
||||
# beginning of a new statement
|
||||
prev = code[self.prev[s]]
|
||||
if (prev == self.opc.ROT_TWO or
|
||||
self.version <= 2.6 and prev == self.opc.JUMP_IF_FALSE):
|
||||
self.version <= 2.6 and prev in
|
||||
(self.opc.JUMP_IF_FALSE, self.opc.JUMP_IF_TRUE)):
|
||||
stmts.remove(s)
|
||||
continue
|
||||
elif code[s] in self.designator_ops:
|
||||
|
@@ -2021,23 +2021,21 @@ class SourceWalker(GenericASTTraversal, object):
|
||||
return
|
||||
|
||||
# build parameters
|
||||
|
||||
params = [build_param(ast, name, default) for
|
||||
name, default in zip_longest(paramnames, defparams, fillvalue=None)]
|
||||
|
||||
params.reverse() # back to correct order
|
||||
|
||||
kw_pairs = 0
|
||||
|
||||
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]])
|
||||
kw_pairs = args_node.attr[1]
|
||||
params.append('*%s' % code.co_varnames[argc + kw_pairs])
|
||||
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
|
||||
|
||||
# dump parameter list (with default values)
|
||||
indent = self.indent
|
||||
if isLambda:
|
||||
@@ -2063,6 +2061,11 @@ class SourceWalker(GenericASTTraversal, object):
|
||||
break
|
||||
pass
|
||||
|
||||
if 8 & code.co_flags: # flag 3 -> keyword args
|
||||
if argc > 0:
|
||||
self.write(', ')
|
||||
self.write('**%s' % code.co_varnames[argc + kw_pairs])
|
||||
|
||||
if isLambda:
|
||||
self.write(": ")
|
||||
else:
|
||||
|
Reference in New Issue
Block a user