From bb461d0d29f3c53bff124269bb0da86da4c57bf871896b4eb26191305016c4d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adrian=20Schr=C3=B6ter?= Date: Fri, 13 Dec 2024 11:23:56 +0100 Subject: [PATCH] Sync from SUSE:SLFO:Main python-executing revision 830f7d8aa6c1f909b73574e4cfbd307b --- _multibuild | 3 + executing-1.2.0.tar.gz | 3 - executing-2.1.0.tar.gz | 3 + new-python-312.patch | 147 +++++++++++++++++++++++++++++++++++++++ python-executing.changes | 91 +++++++++++++++++++++++- python-executing.spec | 64 ++++++++++++----- 6 files changed, 286 insertions(+), 25 deletions(-) create mode 100644 _multibuild delete mode 100644 executing-1.2.0.tar.gz create mode 100644 executing-2.1.0.tar.gz create mode 100644 new-python-312.patch diff --git a/_multibuild b/_multibuild new file mode 100644 index 0000000..fcc7b97 --- /dev/null +++ b/_multibuild @@ -0,0 +1,3 @@ + + test + diff --git a/executing-1.2.0.tar.gz b/executing-1.2.0.tar.gz deleted file mode 100644 index 4190240..0000000 --- a/executing-1.2.0.tar.gz +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:19da64c18d2d851112f09c287f8d3dbbdf725ab0e569077efb6cdcbd3497c107 -size 654544 diff --git a/executing-2.1.0.tar.gz b/executing-2.1.0.tar.gz new file mode 100644 index 0000000..ed6be13 --- /dev/null +++ b/executing-2.1.0.tar.gz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:8ea27ddd260da8150fa5a708269c4a10e76161e2496ec3e587da9e3c0fe4b9ab +size 977485 diff --git a/new-python-312.patch b/new-python-312.patch new file mode 100644 index 0000000..6e5324a --- /dev/null +++ b/new-python-312.patch @@ -0,0 +1,147 @@ +From 4acebfaa89196785ccc893d56b97ac8598c30e71 Mon Sep 17 00:00:00 2001 +From: Frank Hoffmann <15r10nk-git@polarbit.de> +Date: Mon, 26 Aug 2024 21:43:13 +0200 +Subject: [PATCH 1/2] fix: backward compatibility fix for changed source + positions in 3.12.6 (#85) + +--- + executing/_position_node_finder.py | 65 ++++++++++ + tests/generate_small_sample.py | 9 - + tests/small_samples/3e40f2921fbaf6ccbabb2fa5c3cd3a42b54914d66f7a67f8b2ade36f89ed761b.py | 3 + tests/test_main.py | 5 + 4 files changed, 79 insertions(+), 3 deletions(-) + +--- a/executing/_position_node_finder.py ++++ b/executing/_position_node_finder.py +@@ -242,6 +242,66 @@ class PositionNodeFinder(object): + # keeping the old behaviour makes it possible to distinguish both cases. + + return node.parent ++ ++ if ( ++ sys.version_info >= (3, 12, 6) ++ and instruction.opname in ("GET_ITER", "FOR_ITER") ++ and isinstance( ++ node.parent.parent, ++ (ast.ListComp, ast.SetComp, ast.DictComp, ast.GeneratorExp), ++ ) ++ and isinstance(node.parent,ast.comprehension) ++ and node is node.parent.iter ++ ): ++ # same as above but only for comprehensions, see: ++ # https://github.com/python/cpython/issues/123142 ++ ++ return node.parent.parent ++ ++ if sys.version_info >= (3, 12,6) and instruction.opname == "CALL": ++ before = self.instruction_before(instruction) ++ if ( ++ before is not None ++ and before.opname == "LOAD_CONST" ++ and before.positions == instruction.positions ++ and isinstance(node.parent, ast.withitem) ++ and node is node.parent.context_expr ++ ): ++ # node positions for with-statements have change ++ # and is now equal to the expression which created the context-manager ++ # https://github.com/python/cpython/pull/120763 ++ ++ # with context_manager: ++ # ... ++ ++ # but there is one problem to distinguish call-expressions from __exit__() ++ ++ # with context_manager(): ++ # ... ++ ++ # the call for __exit__ ++ ++ # 20 1:5 1:22 LOAD_CONST(None) ++ # 22 1:5 1:22 LOAD_CONST(None) ++ # 24 1:5 1:22 LOAD_CONST(None) ++ # 26 1:5 1:22 CALL() # <-- same source range as context_manager() ++ ++ # but we can use the fact that the previous load for None ++ # has the same source range as the call, wich can not happen for normal calls ++ ++ # we return the same ast.With statement at the and to preserve backward compatibility ++ ++ return node.parent.parent ++ ++ if ( ++ sys.version_info >= (3, 12,6) ++ and instruction.opname == "BEFORE_WITH" ++ and isinstance(node.parent, ast.withitem) ++ and node is node.parent.context_expr ++ ): ++ # handle positions changes for __enter__ ++ return node.parent.parent ++ + return node + + def known_issues(self, node: EnhancedAST, instruction: dis.Instruction) -> None: +@@ -880,6 +940,11 @@ class PositionNodeFinder(object): + def instruction(self, index: int) -> Optional[dis.Instruction]: + return self.bc_dict.get(index,None) + ++ def instruction_before( ++ self, instruction: dis.Instruction ++ ) -> Optional[dis.Instruction]: ++ return self.bc_dict.get(instruction.offset - 2, None) ++ + def opname(self, index: int) -> str: + i=self.instruction(index) + if i is None: +--- a/tests/generate_small_sample.py ++++ b/tests/generate_small_sample.py +@@ -18,6 +18,7 @@ from rich.progress import Progress, trac + from rich.syntax import Syntax + from rich.console import Console + import argparse ++import ast + + last_samples_dir = Path(__file__).parent / "last_samples" + last_samples_dir.mkdir(exist_ok=True) +@@ -64,6 +65,11 @@ def test_file(filename: Path): + + test = TestFiles() + try: ++ ast.parse(code) ++ except (RecursionError,SyntaxError): ++ return True ++ ++ try: + with open(os.devnull, "w") as dev_null: + with contextlib.redirect_stderr(dev_null): + with contextlib.redirect_stdout(dev_null): +@@ -122,9 +128,6 @@ def main(): + break_file.unlink() + sys.exit(0) + +- if time.time() > end_time: +- print("Timeout") +- sys.exit(0) + + if not result: + print(f"{filename} is failing the tests -> minimize\n") +--- /dev/null ++++ b/tests/small_samples/3e40f2921fbaf6ccbabb2fa5c3cd3a42b54914d66f7a67f8b2ade36f89ed761b.py +@@ -0,0 +1,3 @@ ++async def wait(): ++ async with something: ++ pass +\ No newline at end of file +--- a/tests/test_main.py ++++ b/tests/test_main.py +@@ -609,6 +609,11 @@ class TestStuff(unittest.TestCase): + assert {i: i for i in iter_test(ast.DictComp)} == {1: 1, 2: 2} + assert list(i for i in iter_test(ast.GeneratorExp)) == [1, 2] + ++ assert [i for j in [0] for i in iter_test(ast.ListComp)] == [1, 2] ++ assert {i for j in [0] for i in iter_test(ast.SetComp)} == {1, 2} ++ assert {i: i for j in [0] for i in iter_test(ast.DictComp)} == {1: 1, 2: 2} ++ assert list(i for j in [0] for i in iter_test(ast.GeneratorExp)) == [1, 2] ++ + for i in iter_test(ast.For): + assert i in (1, 2) + diff --git a/python-executing.changes b/python-executing.changes index 1463776..865d59e 100644 --- a/python-executing.changes +++ b/python-executing.changes @@ -1,3 +1,88 @@ +------------------------------------------------------------------- +Wed Oct 23 13:02:57 UTC 2024 - Daniel Garcia + +- Remove ipython dependency for Leap + +------------------------------------------------------------------- +Thu Sep 26 09:27:25 UTC 2024 - Matej Cepl + +- Split test run into separate build using _multibuild. + +------------------------------------------------------------------- +Fri Sep 20 20:29:20 UTC 2024 - Matej Cepl + +- The test suite has to be run with pytest, unittest is not enough +- Add missing BuildRequires: ipython + +------------------------------------------------------------------- +Wed Sep 18 06:18:15 UTC 2024 - Markéta Machová + +- Add new-python-312.patch to fix build with recent Python 3.12 release + +------------------------------------------------------------------- +Tue Sep 10 07:06:40 UTC 2024 - John Paul Adrian Glaubitz + +- Update to 2.1.0 + * Add many_calls tests to EXECUTING_SLOW_TESTS (#78) + * fix: backward compatibility fix for changed source positions in 3.12.5 (#82) (#83) + * fix(3.13): show_caches is deprecated + * fix(3.13): added new rules to the verification + * build(3.13): added 3.13 to ci workflow + * fix(3.13): fixed typing errors + * fix(3.13): handle STORE_FAST_STORE_FAST and similar instructions as known issues + * fix(3.13): loading of __class__ is mapped to the last element of the class + * fix(3.13): handle CALL_KW like method calls which are only located by the end position + * fix(3.13): a lambda can also have nonlocal variables + * fix(3.13): a async function can also have nonlocal variables + * fix(3.13): COMPARE_OP maps always to ast.Compare + * fix(3.13): a type variable can also have nonlocal variables + * test(3.13): handle optimization of `not not x` + * test: fixed tests for 3.13.0b1 + * fix: allow to LOAD_FAST variables for TypeVars + * fix: skip files with raise an recursion error in 3.13, + because the recursion limit has no effect + * test(3.13): added sample_results + * test: skip module tests for now + * refactor: review changes + * fix: handle __firstlineno__ + * fix: removed unused verification + * doc: review changes + * Catch exception if node is in unexpected statement (#84) + * test: optimized test preformance by moving deadcode check to the end (#89) + * add 3.13 to setup.cfg classifiers +- Drop support-new-python-3.12.patch, merged upstream + +------------------------------------------------------------------- +Mon Aug 26 02:31:27 UTC 2024 - Steve Kowalik + +- Switch to autosetup macro. +- Add patch support-new-python-3.12.patch: + * Support Python 3.13 (and backported to 3.12.5) AST changes for For. + +------------------------------------------------------------------- +Tue Nov 7 18:46:01 UTC 2023 - Dirk Müller + +- update to 2.0.1: + * fix: self.fail() is only available in TestCase classes + * fix: mark expressions which can be evaluated at compile time + as deadcode + * fix: implemented DELETE_DEREF + * feat: 3.12 support for the PositionNodeFinder + * feat: support LOAD_CONST + * test: verify exception generation for asserts >= python 3.11.2 + * test: skip test of module_files for the SentinelNodeFinder + * test: do not check qualnames for files with syntax errors + * fix: handle List/Set/DictComp inlining + * fix: handle super optimization + * fix: type parameter related things + * fix: f-string + * fix: disabled type checking for 3.12 + * test: added test results for 3.12 + * fix: workaround for a bug in six + * remove python2 code + * feat: support for __iter__ + * feat: support for __next__ + ------------------------------------------------------------------- Fri Apr 21 12:24:50 UTC 2023 - Dirk Müller @@ -27,13 +112,13 @@ Fri Dec 2 17:32:34 UTC 2022 - Yogalakshmi Arunachalam - Update to 0.10.0 Merge pull request #45 from alexmojaki/reload - Clear caches when modules are reloaded + Clear caches when modules are reloaded - Update to 0.9.1 Merge pull request #41 from alexmojaki/node_linenos Extract node_linenos to account for end_lineno and use in assert_linenos -- Update to 0.9.0 +- Update to 0.9.0 * Merge pull request #38 from alexmojaki/pwwang/master Support STORE_ATTR and STORE_SUBSCR @@ -41,7 +126,7 @@ Fri Dec 2 17:32:34 UTC 2022 - Yogalakshmi Arunachalam Sun Mar 27 10:48:50 UTC 2022 - Dirk Müller - update to 0.8.3: - * handle new iphython cell code names + * handle new iphython cell code names * link to futurecoder ------------------------------------------------------------------- diff --git a/python-executing.spec b/python-executing.spec index 3cfa1df..6b0a632 100644 --- a/python-executing.spec +++ b/python-executing.spec @@ -1,7 +1,7 @@ # # spec file for package python-executing # -# Copyright (c) 2023 SUSE LLC +# Copyright (c) 2024 SUSE LLC # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -16,52 +16,78 @@ # -%{?!python_module:%define python_module() python-%{**} python3-%{**}} -%define skip_python2 1 -%define skip_python36 1 +%global flavor @BUILD_FLAVOR@%{nil} +%if "%{flavor}" == "test" +%define psuffix -test +%bcond_without test +%else +%define psuffix %{nil} +%bcond_with test +%endif %{?sle15_python_module_pythons} -Name: python-executing -Version: 1.2.0 +Name: python-executing%{psuffix} +Version: 2.1.0 Release: 0 -License: MIT Summary: Get the currently executing AST node of a frame, and other information +License: MIT URL: https://github.com/alexmojaki/executing -Group: Development/Languages/Python -#Source: https://github.com/alexmojaki/executing/archive/v%%{version}/%%{name}-%%{version}.tar.gz Source: https://files.pythonhosted.org/packages/source/e/executing/executing-%{version}.tar.gz -BuildRequires: %{python_module asttokens} +# PATCH-FIX-UPSTREAM https://github.com/alexmojaki/executing/pull/86 fix: backward compatibility fix for changed source positions in 3.12.6 +Patch0: new-python-312.patch BuildRequires: %{python_module devel} -BuildRequires: %{python_module littleutils} -BuildRequires: %{python_module pytest} +BuildRequires: %{python_module pip} BuildRequires: %{python_module setuptools_scm >= 4.0.0} -BuildRequires: %{python_module setuptools} BuildRequires: %{python_module toml} BuildRequires: %{python_module wheel} BuildRequires: fdupes BuildRequires: python-rpm-macros BuildArch: noarch - +%if %{with test} +BuildRequires: %{python_module asttokens} +%if 0%{?suse_version} > 1600 +BuildRequires: %{python_module ipython} +%endif +BuildRequires: %{python_module littleutils} +BuildRequires: %{python_module pytest} +BuildRequires: %{python_module rich} +%endif %python_subpackages %description Get the currently executing AST node of a frame, and other information %prep -%setup -q -n executing-%{version} +%autosetup -p1 -n executing-%{version} %build -%python_build +%if %{without test} +%pyproject_wheel +%endif %install -%python_install +%if %{without test} +%pyproject_install %python_expand %fdupes %{buildroot}%{$python_sitelib} +%endif %check -%pyunittest discover -v +%if %{with test} +# Don't have ipython build requirement in Leap +%if 0%{?suse_version} <= 1600 +%pytest -k "not test_ipython" +%else +%pytest +%endif + +%endif + +%if %{without test} %files %{python_files} %doc README.md %license LICENSE.txt -%{python_sitelib}/* +%{python_sitelib}/executing +%{python_sitelib}/executing-%{version}.dist-info +%endif %changelog