You've already forked python-uncompyle6
mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2025-08-03 16:59:52 +08:00
Start to handle 3.5+ BUILD_LIST_UNPACK in call ..
to implement multple star arguments
This commit is contained in:
Binary file not shown.
@@ -1,9 +1,17 @@
|
|||||||
# Bug in Python 3.5 is getting the two star'd arguments right.
|
# Bug in 3.5 is detecting when there is more than
|
||||||
def sum(a,b,c,d):
|
# one * in a call. There is a "BUILD_UNPACK_LIST" instruction used
|
||||||
|
# to unpack star arguments
|
||||||
|
def sum(a, b, c, d):
|
||||||
return a + b + c + d
|
return a + b + c + d
|
||||||
|
a, b, c = 1, 2, 3
|
||||||
args=(1,2)
|
args = (1, 2)
|
||||||
sum(*args, *args)
|
sum(*args, *args)
|
||||||
|
|
||||||
|
# FIXME: these is handled incorrectly
|
||||||
|
|
||||||
|
# sum(a, *args, *args)
|
||||||
|
|
||||||
|
# sum(a, b, *args)
|
||||||
|
|
||||||
# FIXME: this is handled incorrectly
|
# FIXME: this is handled incorrectly
|
||||||
# (*c,) = (3,4)
|
# (*c,) = (3,4)
|
||||||
|
@@ -282,12 +282,22 @@ def customize_for_version(self, is_pypy, version):
|
|||||||
node[kwarg_pos], node[args_pos] = node[args_pos], node[kwarg_pos]
|
node[kwarg_pos], node[args_pos] = node[args_pos], node[kwarg_pos]
|
||||||
args_pos = kwarg_pos
|
args_pos = kwarg_pos
|
||||||
kwarg_pos += 1
|
kwarg_pos += 1
|
||||||
elif key.kind == 'CALL_FUNCTION_VAR_0' and node[1][0] == 'build_list_unpack':
|
elif key.kind.startswith('CALL_FUNCTION_VAR'):
|
||||||
self.preorder(node[0])
|
nargs = node[-1].attr
|
||||||
build_list_unpack = node[1][0]
|
args_node = node[-2]
|
||||||
template = ('(*%P)', (0, len(build_list_unpack)-1, ', *', 100))
|
if args_node == 'pos_arg':
|
||||||
self.template_engine(template, build_list_unpack)
|
args_node = args_node[0]
|
||||||
self.prune()
|
if args_node == 'expr':
|
||||||
|
args_node = args_node[0]
|
||||||
|
if nargs > 0:
|
||||||
|
template = ('%c(%C, ', 0, (0, nargs, ', '))
|
||||||
|
else:
|
||||||
|
template = ('%c(', 0)
|
||||||
|
self.template_engine(template, node)
|
||||||
|
if args_node == 'build_list_unpack':
|
||||||
|
template = ('*%P)', (0, len(args_node)-1, ', *', 100))
|
||||||
|
self.template_engine(template, args_node)
|
||||||
|
self.prune()
|
||||||
|
|
||||||
self.default(node)
|
self.default(node)
|
||||||
self.n_call = n_call
|
self.n_call = n_call
|
||||||
|
Reference in New Issue
Block a user