From 5616f564427967a73bcb203a423b62fab11db086 Mon Sep 17 00:00:00 2001 From: rocky Date: Fri, 24 Jan 2020 05:05:56 -0500 Subject: [PATCH] Remove unreachable code from make_function36.py... with respect to picking out MAKE_FUNCTION attributes. Fill in runtests.sh exclude lists --- test/stdlib/2.7-exclude.sh | 1 + test/stdlib/3.4-exclude.sh | 2 +- test/stdlib/3.6-exclude.sh | 2 +- test/stdlib/3.7-exclude.sh | 2 +- uncompyle6/semantics/make_function36.py | 91 +++++++------------------ 5 files changed, 27 insertions(+), 71 deletions(-) diff --git a/test/stdlib/2.7-exclude.sh b/test/stdlib/2.7-exclude.sh index e3223c3e..1d4d4f6c 100644 --- a/test/stdlib/2.7-exclude.sh +++ b/test/stdlib/2.7-exclude.sh @@ -32,3 +32,4 @@ SKIP_TESTS=( [test_zipfile64.py]=1 # Runs ok but takes 204 seconds [test_zipimport.py]=1 # ) +# 335 unit-test files in about 16 minutes diff --git a/test/stdlib/3.4-exclude.sh b/test/stdlib/3.4-exclude.sh index 50338b1f..f1a599ed 100644 --- a/test/stdlib/3.4-exclude.sh +++ b/test/stdlib/3.4-exclude.sh @@ -99,4 +99,4 @@ SKIP_TESTS=( [test_zipimport_support.py]=1 [test_zlib.py]=1 ) -# 249 unit-test file in about 7 minutes and 44 seconds +# 272 unit-test file in about 15 minutes diff --git a/test/stdlib/3.6-exclude.sh b/test/stdlib/3.6-exclude.sh index ab16dc1b..87b0e40a 100644 --- a/test/stdlib/3.6-exclude.sh +++ b/test/stdlib/3.6-exclude.sh @@ -183,4 +183,4 @@ SKIP_TESTS=( [test_zipimport_support.py]=1 [test_zlib.py]=1 ) -# 218 unit-test remaining files, Elapsed time about 7 minutes 30 seconds +# 233 unit-test files in about 13 minutes diff --git a/test/stdlib/3.7-exclude.sh b/test/stdlib/3.7-exclude.sh index e884a705..4cdd218b 100644 --- a/test/stdlib/3.7-exclude.sh +++ b/test/stdlib/3.7-exclude.sh @@ -125,4 +125,4 @@ SKIP_TESTS=( [test_zipfile.py]=1 # it fails on its own [test_zipfile64.py]=1 # Too long to run ) -# 268 Remaining unit-test files, Elapsed time about 11 minutes +# 271 unit-test files in about 14 minutes diff --git a/uncompyle6/semantics/make_function36.py b/uncompyle6/semantics/make_function36.py index 02f0f7f2..325e226b 100644 --- a/uncompyle6/semantics/make_function36.py +++ b/uncompyle6/semantics/make_function36.py @@ -87,79 +87,17 @@ def make_function36(self, node, is_lambda, nested=1, code_node=None): # not to be confused with keyword parameters which may appear after *. args_attr = args_node.attr - if isinstance(args_attr, tuple) or isinstance(args_attr, list): - if len(args_attr) == 3: - pos_args, kw_args, annotate_argc = args_attr - else: - pos_args, kw_args, annotate_argc, closure = args_attr - - i = -4 - kw_pairs = 0 - if closure: - # FIXME: fill in - i -= 1 - if annotate_argc: - # Turn into subroutine and DRY with other use - annotate_node = node[i] - if annotate_node == "expr": - annotate_node = annotate_node[0] - annotate_name_node = annotate_node[-1] - if annotate_node == "dict" and annotate_name_node.kind.startswith( - "BUILD_CONST_KEY_MAP" - ): - types = [ - self.traverse(n, indent="") for n in annotate_node[:-2] - ] - names = annotate_node[-2].attr - l = len(types) - assert l == len(names) - for i in range(l): - annotate_dict[names[i]] = types[i] - pass - pass - i -= 1 - if kw_args: - kw_node = node[i] - if kw_node == "expr": - kw_node = kw_node[0] - if kw_node == "dict": - kw_pairs = kw_node[-1].attr - - defparams = [] - # FIXME: DRY with code below - default, kw_args, annotate_argc = args_node.attr[0:3] - if default: - expr_node = node[0] - if node[0] == "pos_arg": - expr_node = expr_node[0] - assert expr_node == "expr", "expecting mkfunc default node to be an expr" - if expr_node[0] == "LOAD_CONST" and isinstance(expr_node[0].attr, tuple): - defparams = [repr(a) for a in expr_node[0].attr] - elif expr_node[0] in frozenset(("list", "tuple", "dict", "set")): - defparams = [self.traverse(n, indent="") for n in expr_node[0][:-1]] - else: - defparams = [] - pass + if len(args_attr) == 3: + pos_args, kw_args, annotate_argc = args_attr else: - default, kw_args, annotate, closure = args_node.attr - if default: - expr_node = node[0] - if node[0] == "pos_arg": - expr_node = expr_node[0] - assert expr_node == "expr", "expecting mkfunc default node to be an expr" - if expr_node[0] == "LOAD_CONST" and isinstance(expr_node[0].attr, tuple): - defparams = [repr(a) for a in expr_node[0].attr] - elif expr_node[0] in frozenset(("list", "tuple", "dict", "set")): - defparams = [self.traverse(n, indent="") for n in expr_node[0][:-1]] - else: - defparams = [] + pos_args, kw_args, annotate_argc, closure = args_attr i = -4 kw_pairs = 0 if closure: # FIXME: fill in - # annotate = node[i] i -= 1 + if annotate_argc: # Turn into subroutine and DRY with other use annotate_node = node[i] @@ -169,7 +107,9 @@ def make_function36(self, node, is_lambda, nested=1, code_node=None): if annotate_node == "dict" and annotate_name_node.kind.startswith( "BUILD_CONST_KEY_MAP" ): - types = [self.traverse(n, indent="") for n in annotate_node[:-2]] + types = [ + self.traverse(n, indent="") for n in annotate_node[:-2] + ] names = annotate_node[-2].attr l = len(types) assert l == len(names) @@ -184,7 +124,22 @@ def make_function36(self, node, is_lambda, nested=1, code_node=None): kw_node = kw_node[0] if kw_node == "dict": kw_pairs = kw_node[-1].attr - pass + + defparams = [] + # FIXME: DRY with code below + default, kw_args, annotate_argc = args_node.attr[0:3] + if default: + expr_node = node[0] + if node[0] == "pos_arg": + expr_node = expr_node[0] + assert expr_node == "expr", "expecting mkfunc default node to be an expr" + if expr_node[0] == "LOAD_CONST" and isinstance(expr_node[0].attr, tuple): + defparams = [repr(a) for a in expr_node[0].attr] + elif expr_node[0] in frozenset(("list", "tuple", "dict", "set")): + defparams = [self.traverse(n, indent="") for n in expr_node[0][:-1]] + else: + defparams = [] + pass if lambda_index and is_lambda and iscode(node[lambda_index].attr): assert node[lambda_index].kind == "LOAD_LAMBDA"