You've already forked python-uncompyle6
mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2025-08-03 16:59:52 +08:00
Fix 3.2 to 3.3 make_function more properly
This commit is contained in:
BIN
test/bytecode_3.2_run/04_call_function.pyc
Normal file
BIN
test/bytecode_3.2_run/04_call_function.pyc
Normal file
Binary file not shown.
@@ -509,6 +509,10 @@ def make_function3(self, node, is_lambda, nested=1, codeNode=None):
|
|||||||
lambda_index = None
|
lambda_index = None
|
||||||
|
|
||||||
args_node = node[-1]
|
args_node = node[-1]
|
||||||
|
|
||||||
|
# Get a list of tree nodes that constitute the "default parameters"
|
||||||
|
# these are default values that appear before any *, and are not
|
||||||
|
# to be confused with keyword parameters which may appear after *.
|
||||||
if isinstance(args_node.attr, tuple):
|
if isinstance(args_node.attr, tuple):
|
||||||
pos_args, kw_args, annotate_argc = args_node.attr
|
pos_args, kw_args, annotate_argc = args_node.attr
|
||||||
# FIXME: there is probably a better way to classify this.
|
# FIXME: there is probably a better way to classify this.
|
||||||
@@ -519,23 +523,25 @@ def make_function3(self, node, is_lambda, nested=1, codeNode=None):
|
|||||||
lc_index = -3
|
lc_index = -3
|
||||||
pass
|
pass
|
||||||
|
|
||||||
default_values_start = 0
|
if (3.2 <= self.version <= 3.3 and len(node) > 2 and
|
||||||
param_str = None
|
node[lambda_index] != 'LOAD_LAMBDA' and
|
||||||
if node[0] == 'no_kwargs':
|
(have_kwargs or node[lc_index].kind != 'load_closure')):
|
||||||
default_values_start += 1
|
|
||||||
|
|
||||||
if not param_str:
|
# Find the index in "node" where the first default
|
||||||
if (3.2 <= self.version <= 3.3 and len(node) > 2 and
|
# parameter value is located. Note this is in contrast to
|
||||||
node[lambda_index] != 'LOAD_LAMBDA' and
|
# key-word arguments, pairs of (name, value), which appear after "*".
|
||||||
(have_kwargs or node[lc_index].kind != 'load_closure')):
|
# "default_values_start" is this location.
|
||||||
# args are after kwargs; kwargs are bundled as one node
|
default_values_start = 0
|
||||||
if self.version == 3.3:
|
if node[0] == 'no_kwargs':
|
||||||
default_values_start += 1
|
default_values_start += 1
|
||||||
defparams = node[default_values_start:args_node.attr[0]+default_values_start]
|
# args are after kwargs; kwargs are bundled as one node
|
||||||
else:
|
if node[default_values_start] == 'kwargs':
|
||||||
# args are before kwargs; kwags as bundled as one node
|
default_values_start += 1
|
||||||
defparams = node[default_values_start:default_values_start+args_node.attr[0]]
|
defparams = node[default_values_start:default_values_start+args_node.attr[0]]
|
||||||
pass
|
else:
|
||||||
|
# args are first, before kwargs.
|
||||||
|
defparams = node[:args_node.attr[0]]
|
||||||
|
pass
|
||||||
else:
|
else:
|
||||||
if self.version < 3.6:
|
if self.version < 3.6:
|
||||||
defparams = node[:args_node.attr]
|
defparams = node[:args_node.attr]
|
||||||
|
Reference in New Issue
Block a user