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.
|
||||
def sum(a,b,c,d):
|
||||
# Bug in 3.5 is detecting when there is more than
|
||||
# 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
|
||||
|
||||
args=(1,2)
|
||||
a, b, c = 1, 2, 3
|
||||
args = (1, 2)
|
||||
sum(*args, *args)
|
||||
|
||||
# FIXME: these is handled incorrectly
|
||||
|
||||
# sum(a, *args, *args)
|
||||
|
||||
# sum(a, b, *args)
|
||||
|
||||
# FIXME: this is handled incorrectly
|
||||
# (*c,) = (3,4)
|
||||
|
@@ -282,11 +282,21 @@ def customize_for_version(self, is_pypy, version):
|
||||
node[kwarg_pos], node[args_pos] = node[args_pos], node[kwarg_pos]
|
||||
args_pos = kwarg_pos
|
||||
kwarg_pos += 1
|
||||
elif key.kind == 'CALL_FUNCTION_VAR_0' and node[1][0] == 'build_list_unpack':
|
||||
self.preorder(node[0])
|
||||
build_list_unpack = node[1][0]
|
||||
template = ('(*%P)', (0, len(build_list_unpack)-1, ', *', 100))
|
||||
self.template_engine(template, build_list_unpack)
|
||||
elif key.kind.startswith('CALL_FUNCTION_VAR'):
|
||||
nargs = node[-1].attr
|
||||
args_node = node[-2]
|
||||
if args_node == 'pos_arg':
|
||||
args_node = args_node[0]
|
||||
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)
|
||||
|
Reference in New Issue
Block a user