From 9fd139a41d8ccd0743bb605189c37813288ace40 Mon Sep 17 00:00:00 2001 From: rocky Date: Sat, 24 Feb 2024 18:26:37 -0500 Subject: [PATCH 1/5] changes from other branches --- test/stdlib/2.6-exclude.sh | 1 + test/stdlib/3.2-exclude.sh | 7 +++++++ test/stdlib/3.3-exclude.sh | 2 +- uncompyle6/semantics/make_function2.py | 20 ++++++++------------ uncompyle6/semantics/make_function3.py | 1 - uncompyle6/semantics/n_actions.py | 2 +- 6 files changed, 18 insertions(+), 15 deletions(-) diff --git a/test/stdlib/2.6-exclude.sh b/test/stdlib/2.6-exclude.sh index 5b395032..952579a4 100644 --- a/test/stdlib/2.6-exclude.sh +++ b/test/stdlib/2.6-exclude.sh @@ -18,6 +18,7 @@ SKIP_TESTS=( [test_cd.py]=1 # i# No module cl [test_cl.py]=1 # it fails on its own + [test_cmath.py]=pytest [test_codecmaps_cn.py]=1 # it fails on its own [test_codecmaps_jp.py]=1 # it fails on its own [test_codecmaps_kr.py]=1 # it fails on its own diff --git a/test/stdlib/3.2-exclude.sh b/test/stdlib/3.2-exclude.sh index 5b61dd9b..f80f9ee8 100644 --- a/test/stdlib/3.2-exclude.sh +++ b/test/stdlib/3.2-exclude.sh @@ -1,6 +1,13 @@ SKIP_TESTS=( [test_descr.py]=1 # FIXME: Works on c90ff51? + [test_cmath.py]=1 # FIXME + # AssertionError: rect1000: rect(complex(0.0, 0.0)) + # Expected: complex(0.0, 0.0) + # Received: complex(0.0, -1.0) + # Received value insufficiently close to expected value. + + [test_cmd_line.py]=1 [test_collections.py]=1 [test_concurrent_futures.py]=1 # too long to run over 46 seconds by itself diff --git a/test/stdlib/3.3-exclude.sh b/test/stdlib/3.3-exclude.sh index ea0efb29..b2d0afe8 100644 --- a/test/stdlib/3.3-exclude.sh +++ b/test/stdlib/3.3-exclude.sh @@ -11,7 +11,7 @@ SKIP_TESTS=( [test_itertools.py]=1 [test_buffer.py]=1 # FIXME: Works on c90ff51 - [test_cmath.py]=1 # FIXME: Works on c90ff51 + [test_cmath.py]=pytest [test_atexit.py]=1 # The atexit test starting at 3.3 looks for specific comments in error lines diff --git a/uncompyle6/semantics/make_function2.py b/uncompyle6/semantics/make_function2.py index fb186f4f..030ec54e 100644 --- a/uncompyle6/semantics/make_function2.py +++ b/uncompyle6/semantics/make_function2.py @@ -1,4 +1,4 @@ -# Copyright (c) 2015-2021 by Rocky Bernstein +# Copyright (c) 2015-2021 2024 by Rocky Bernstein # Copyright (c) 2000-2002 by hartmut Goebel # # This program is free software: you can redistribute it and/or modify @@ -17,20 +17,17 @@ All the crazy things we have to do to handle Python functions in Python before 3.0. The saga of changes continues in 3.0 and above and in other files. """ +from xdis import code_has_star_arg, code_has_star_star_arg, iscode + from uncompyle6.scanner import Code -from uncompyle6.semantics.parser_error import ParserError -from uncompyle6.parser import ParserError as ParserError2 from uncompyle6.semantics.helper import ( - print_docstring, find_all_globals, find_globals_and_nonlocals, find_none, + print_docstring, ) -from xdis import iscode, code_has_star_arg, code_has_star_star_arg +from uncompyle6.semantics.parser_error import ParserError -from itertools import zip_longest - -from uncompyle6.show import maybe_show_tree_param_default def make_function2(self, node, is_lambda, nested=1, code_node=None): """ @@ -40,8 +37,8 @@ def make_function2(self, node, is_lambda, nested=1, code_node=None): def build_param(ast, name, default): """build parameters: - - handle defaults - - handle format tuple parameters + - handle defaults + - handle format tuple parameters """ # if formal parameter is a tuple, the paramater name # starts with a dot (eg. '.1', '.2') @@ -52,7 +49,6 @@ def make_function2(self, node, is_lambda, nested=1, code_node=None): if default: value = self.traverse(default, indent="") - maybe_show_tree_param_default(self.showast, name, value) result = "%s=%s" % (name, value) if result[-2:] == "= ": # default was 'LOAD_CONST None' result += "None" @@ -199,5 +195,5 @@ def make_function2(self, node, is_lambda, nested=1, code_node=None): ast, code.co_name, code._customize, is_lambda=is_lambda, returnNone=rn ) - code._tokens = None # save memory + code._tokens = None # save memory code._customize = None # save memory diff --git a/uncompyle6/semantics/make_function3.py b/uncompyle6/semantics/make_function3.py index 7c2960ee..a7377f61 100644 --- a/uncompyle6/semantics/make_function3.py +++ b/uncompyle6/semantics/make_function3.py @@ -337,7 +337,6 @@ def make_function3(self, node, is_lambda, nested=1, code_node=None): - handle format tuple parameters """ value = self.traverse(default, indent="") - maybe_show_tree_param_default(self.showast, name, value) if annotation: result = "%s: %s=%s" % (name, annotation, value) else: diff --git a/uncompyle6/semantics/n_actions.py b/uncompyle6/semantics/n_actions.py index a1e8d770..83619f77 100644 --- a/uncompyle6/semantics/n_actions.py +++ b/uncompyle6/semantics/n_actions.py @@ -278,7 +278,7 @@ class NonterminalActions: elif elem.optype == "const" and not isinstance(elem.attr, str): value = elem.attr else: - value = "%s" % repr(elem.pattr) + value = "%s" % repr(elem.attr) else: assert elem.kind == "ADD_VALUE_VAR" value = "%s" % elem.pattr From 4a50de38e41454ac7db7746c5f654e031ae07a9e Mon Sep 17 00:00:00 2001 From: rocky Date: Sat, 24 Feb 2024 18:31:57 -0500 Subject: [PATCH 2/5] sync with other versions --- uncompyle6/semantics/make_function2.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/uncompyle6/semantics/make_function2.py b/uncompyle6/semantics/make_function2.py index 030ec54e..43f87057 100644 --- a/uncompyle6/semantics/make_function2.py +++ b/uncompyle6/semantics/make_function2.py @@ -17,6 +17,9 @@ All the crazy things we have to do to handle Python functions in Python before 3.0. The saga of changes continues in 3.0 and above and in other files. """ + +from itertools import zip_longest + from xdis import code_has_star_arg, code_has_star_star_arg, iscode from uncompyle6.scanner import Code From 2b8406e7a819155e2c5df826ca39b19e21dcb2c0 Mon Sep 17 00:00:00 2001 From: rocky Date: Sun, 25 Feb 2024 06:08:06 -0500 Subject: [PATCH 3/5] mark "psuedo ops" --- uncompyle6/scanners/scanner3.py | 6 +++--- uncompyle6/scanners/scanner37.py | 2 +- uncompyle6/semantics/pysource.py | 2 +- uncompyle6/semantics/transform.py | 16 +++------------- 4 files changed, 8 insertions(+), 18 deletions(-) diff --git a/uncompyle6/scanners/scanner3.py b/uncompyle6/scanners/scanner3.py index 3c51c3e6..634417af 100644 --- a/uncompyle6/scanners/scanner3.py +++ b/uncompyle6/scanners/scanner3.py @@ -266,7 +266,7 @@ class Scanner3(Scanner): has_arg=True, has_extended_arg=False, opc=self.opc, - optype=None, + optype="pseudo", ) ) for j in range(collection_start, i): @@ -293,7 +293,7 @@ class Scanner3(Scanner): has_arg=t.has_arg, has_extended_arg=False, opc=t.opc, - optype=None, + optype="pseudo", ) ) return new_tokens @@ -342,7 +342,7 @@ class Scanner3(Scanner): has_arg=True, has_extended_arg=False, opc=self.opc, - optype=None, + optype="pseudo", ) ) for j in range(collection_start, i, 2): diff --git a/uncompyle6/scanners/scanner37.py b/uncompyle6/scanners/scanner37.py index ea6db8ac..894da02c 100644 --- a/uncompyle6/scanners/scanner37.py +++ b/uncompyle6/scanners/scanner37.py @@ -90,7 +90,7 @@ class Scanner37(Scanner37Base): has_arg=True, has_extended_arg=False, opc=self.opc, - optype=None, + optype="pseudo", ) ) for j in range(collection_start, i): diff --git a/uncompyle6/semantics/pysource.py b/uncompyle6/semantics/pysource.py index 31dc542a..c351337e 100644 --- a/uncompyle6/semantics/pysource.py +++ b/uncompyle6/semantics/pysource.py @@ -1267,7 +1267,7 @@ class SourceWalker(GenericASTTraversal, NonterminalActions, ComprehensionMixin): transform_tree = self.treeTransform.transform(ast, code) - self.maybe_show_tree(ast, phase="before") + self.maybe_show_tree(transform_tree, phase="after") del ast # Save memory return transform_tree diff --git a/uncompyle6/semantics/transform.py b/uncompyle6/semantics/transform.py index 430f1e0f..fee594ba 100644 --- a/uncompyle6/semantics/transform.py +++ b/uncompyle6/semantics/transform.py @@ -489,19 +489,9 @@ class TreeTransform(GenericASTTraversal, object): self.ast[i] = self.ast[i][0] if is_docstring(self.ast[i], self.version, code.co_consts): - load_const = self.ast[i].first_child() - docstring_ast = SyntaxTree( - "docstring", - [ - Token( - "LOAD_STR", - has_arg=True, - offset=0, - attr=load_const.attr, - pattr=load_const.pattr, - ) - ], - ) + load_const = copy(self.ast[i].first_child()) + store_name = copy(self.ast[i].last_child()) + docstring_ast = SyntaxTree("docstring", [load_const, store_name]) docstring_ast.transformed_by = "transform" del self.ast[i] self.ast.insert(0, docstring_ast) From 404517e426b50aaa2f45c1054e9f48c8fa10afb3 Mon Sep 17 00:00:00 2001 From: rocky Date: Sun, 25 Feb 2024 06:09:01 -0500 Subject: [PATCH 4/5] Admnistrivia --- admin-tools/merge-for-3.3.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/admin-tools/merge-for-3.3.sh b/admin-tools/merge-for-3.3.sh index aade2e77..8febb3d9 100755 --- a/admin-tools/merge-for-3.3.sh +++ b/admin-tools/merge-for-3.3.sh @@ -1,5 +1,7 @@ #/bin/bash +owd=$(pwd) cd $(dirname ${BASH_SOURCE[0]}) if . ./setup-python-3.3.sh; then git merge master fi +cd $owd From d9ff58391f74110ef026d7d9ae380ba0505b1293 Mon Sep 17 00:00:00 2001 From: rocky Date: Sun, 25 Feb 2024 06:09:01 -0500 Subject: [PATCH 5/5] Admnistrivia --- admin-tools/merge-for-2.4.sh | 2 ++ admin-tools/merge-for-3.0.sh | 2 ++ admin-tools/merge-for-3.3.sh | 2 ++ 3 files changed, 6 insertions(+) diff --git a/admin-tools/merge-for-2.4.sh b/admin-tools/merge-for-2.4.sh index f8c55395..38b38124 100755 --- a/admin-tools/merge-for-2.4.sh +++ b/admin-tools/merge-for-2.4.sh @@ -1,5 +1,7 @@ #/bin/bash +owd=$(pwd) cd $(dirname ${BASH_SOURCE[0]}) if . ./setup-python-2.4.sh; then git merge python-3.0-to-3.2 fi +cd $owd diff --git a/admin-tools/merge-for-3.0.sh b/admin-tools/merge-for-3.0.sh index 7fc1a596..834e9a25 100755 --- a/admin-tools/merge-for-3.0.sh +++ b/admin-tools/merge-for-3.0.sh @@ -1,5 +1,7 @@ #/bin/bash +owd=$(pwd) cd $(dirname ${BASH_SOURCE[0]}) if . ./setup-python-3.0.sh; then git merge python-3.3-to-3.5 fi +cd $owd diff --git a/admin-tools/merge-for-3.3.sh b/admin-tools/merge-for-3.3.sh index aade2e77..8febb3d9 100755 --- a/admin-tools/merge-for-3.3.sh +++ b/admin-tools/merge-for-3.3.sh @@ -1,5 +1,7 @@ #/bin/bash +owd=$(pwd) cd $(dirname ${BASH_SOURCE[0]}) if . ./setup-python-3.3.sh; then git merge master fi +cd $owd