- Add pytest.patch to fix compatibility with new pytest
OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-executing?expand=0&rev=24
This commit is contained in:
commit
99e2f9fe62
23
.gitattributes
vendored
Normal file
23
.gitattributes
vendored
Normal file
@ -0,0 +1,23 @@
|
||||
## Default LFS
|
||||
*.7z filter=lfs diff=lfs merge=lfs -text
|
||||
*.bsp filter=lfs diff=lfs merge=lfs -text
|
||||
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
||||
*.gem filter=lfs diff=lfs merge=lfs -text
|
||||
*.gz filter=lfs diff=lfs merge=lfs -text
|
||||
*.jar filter=lfs diff=lfs merge=lfs -text
|
||||
*.lz filter=lfs diff=lfs merge=lfs -text
|
||||
*.lzma filter=lfs diff=lfs merge=lfs -text
|
||||
*.obscpio filter=lfs diff=lfs merge=lfs -text
|
||||
*.oxt filter=lfs diff=lfs merge=lfs -text
|
||||
*.pdf filter=lfs diff=lfs merge=lfs -text
|
||||
*.png filter=lfs diff=lfs merge=lfs -text
|
||||
*.rpm filter=lfs diff=lfs merge=lfs -text
|
||||
*.tbz filter=lfs diff=lfs merge=lfs -text
|
||||
*.tbz2 filter=lfs diff=lfs merge=lfs -text
|
||||
*.tgz filter=lfs diff=lfs merge=lfs -text
|
||||
*.ttf filter=lfs diff=lfs merge=lfs -text
|
||||
*.txz filter=lfs diff=lfs merge=lfs -text
|
||||
*.whl filter=lfs diff=lfs merge=lfs -text
|
||||
*.xz filter=lfs diff=lfs merge=lfs -text
|
||||
*.zip filter=lfs diff=lfs merge=lfs -text
|
||||
*.zst filter=lfs diff=lfs merge=lfs -text
|
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
.osc
|
3
_multibuild
Normal file
3
_multibuild
Normal file
@ -0,0 +1,3 @@
|
||||
<multibuild>
|
||||
<package>test</package>
|
||||
</multibuild>
|
3
executing-2.0.1.tar.gz
Normal file
3
executing-2.0.1.tar.gz
Normal file
@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:35afe2ce3affba8ee97f2d69927fa823b08b472b7b994e36a52a964b93d16147
|
||||
size 836501
|
BIN
executing-2.1.0.tar.gz
(Stored with Git LFS)
Normal file
BIN
executing-2.1.0.tar.gz
(Stored with Git LFS)
Normal file
Binary file not shown.
147
new-python-312.patch
Normal file
147
new-python-312.patch
Normal file
@ -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)
|
||||
|
125
pytest.patch
Normal file
125
pytest.patch
Normal file
@ -0,0 +1,125 @@
|
||||
From 0edb6ca3d733d8cb3fd1ddc7994bde61991ac4c2 Mon Sep 17 00:00:00 2001
|
||||
From: Frank Hoffmann <44680962+15r10nk@users.noreply.github.com>
|
||||
Date: Sun, 12 Jan 2025 17:03:09 +0100
|
||||
Subject: [PATCH] fix: check for pytest compatibility (#94)
|
||||
|
||||
---
|
||||
executing/__init__.py | 5 ++++-
|
||||
executing/_pytest_utils.py | 16 ++++++++++++++++
|
||||
tests/conftest.py | 25 +++++++++++++++++++++++++
|
||||
tests/test_main.py | 5 -----
|
||||
tests/test_pytest.py | 5 +++++
|
||||
5 files changed, 50 insertions(+), 6 deletions(-)
|
||||
create mode 100644 executing/_pytest_utils.py
|
||||
create mode 100644 tests/conftest.py
|
||||
|
||||
diff --git a/executing/__init__.py b/executing/__init__.py
|
||||
index b645197..e5181a5 100644
|
||||
--- a/executing/__init__.py
|
||||
+++ b/executing/__init__.py
|
||||
@@ -10,6 +10,9 @@
|
||||
from collections import namedtuple
|
||||
_VersionInfo = namedtuple('_VersionInfo', ('major', 'minor', 'micro'))
|
||||
from .executing import Source, Executing, only, NotOneValueFound, cache, future_flags
|
||||
+
|
||||
+from ._pytest_utils import is_pytest_compatible
|
||||
+
|
||||
try:
|
||||
from .version import __version__ # type: ignore[import]
|
||||
if "dev" in __version__:
|
||||
@@ -22,4 +25,4 @@
|
||||
__version_info__ = _VersionInfo(*map(int, __version__.split('.')))
|
||||
|
||||
|
||||
-__all__ = ["Source"]
|
||||
+__all__ = ["Source","is_pytest_compatible"]
|
||||
diff --git a/executing/_pytest_utils.py b/executing/_pytest_utils.py
|
||||
new file mode 100644
|
||||
index 0000000..fab8693
|
||||
--- /dev/null
|
||||
+++ b/executing/_pytest_utils.py
|
||||
@@ -0,0 +1,16 @@
|
||||
+import sys
|
||||
+
|
||||
+
|
||||
+
|
||||
+def is_pytest_compatible() -> bool:
|
||||
+ """ returns true if executing can be used for expressions inside assert statements which are rewritten by pytest
|
||||
+ """
|
||||
+ if sys.version_info < (3, 11):
|
||||
+ return False
|
||||
+
|
||||
+ try:
|
||||
+ import pytest
|
||||
+ except ImportError:
|
||||
+ return False
|
||||
+
|
||||
+ return pytest.version_tuple >= (8, 3, 4)
|
||||
diff --git a/tests/conftest.py b/tests/conftest.py
|
||||
new file mode 100644
|
||||
index 0000000..5108348
|
||||
--- /dev/null
|
||||
+++ b/tests/conftest.py
|
||||
@@ -0,0 +1,25 @@
|
||||
+
|
||||
+
|
||||
+from typing import Optional, Sequence, Union
|
||||
+from executing._pytest_utils import is_pytest_compatible
|
||||
+import _pytest.assertion.rewrite as rewrite
|
||||
+import importlib.machinery
|
||||
+import types
|
||||
+
|
||||
+if not is_pytest_compatible():
|
||||
+ original_find_spec = rewrite.AssertionRewritingHook.find_spec
|
||||
+
|
||||
+
|
||||
+ def find_spec(
|
||||
+ self,
|
||||
+ name: str,
|
||||
+ path: Optional[Sequence[Union[str, bytes]]] = None,
|
||||
+ target: Optional[types.ModuleType] = None,
|
||||
+ ) -> Optional[importlib.machinery.ModuleSpec]:
|
||||
+
|
||||
+ if name == "tests.test_main":
|
||||
+ return None
|
||||
+ return original_find_spec(self, name, path, target)
|
||||
+
|
||||
+
|
||||
+ rewrite.AssertionRewritingHook.find_spec = find_spec
|
||||
diff --git a/tests/test_main.py b/tests/test_main.py
|
||||
index a3f92ee..e3bc9d6 100644
|
||||
--- a/tests/test_main.py
|
||||
+++ b/tests/test_main.py
|
||||
@@ -1,9 +1,4 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
-"""
|
||||
-
|
||||
-assert rewriting will break executing
|
||||
-PYTEST_DONT_REWRITE
|
||||
-"""
|
||||
from __future__ import print_function, division
|
||||
import ast
|
||||
import contextlib
|
||||
diff --git a/tests/test_pytest.py b/tests/test_pytest.py
|
||||
index 281598d..5cbe0a2 100644
|
||||
--- a/tests/test_pytest.py
|
||||
+++ b/tests/test_pytest.py
|
||||
@@ -6,6 +6,7 @@
|
||||
from time import sleep
|
||||
|
||||
import asttokens
|
||||
+from executing._pytest_utils import is_pytest_compatible
|
||||
import pytest
|
||||
from littleutils import SimpleNamespace
|
||||
|
||||
@@ -124,6 +125,10 @@ def check_manual_linecache(filename):
|
||||
def test_exception_catching():
|
||||
frame = inspect.currentframe()
|
||||
|
||||
+ if is_pytest_compatible():
|
||||
+ assert isinstance(Source.executing(frame).node,ast.Call)
|
||||
+ return
|
||||
+
|
||||
executing.executing.TESTING = True # this is already the case in all other tests
|
||||
# Sanity check that this operation usually raises an exception.
|
||||
# This actually depends on executing not working in the presence of pytest.
|
168
python-executing.changes
Normal file
168
python-executing.changes
Normal file
@ -0,0 +1,168 @@
|
||||
-------------------------------------------------------------------
|
||||
Fri Jan 17 16:19:38 UTC 2025 - Markéta Machová <mmachova@suse.com>
|
||||
|
||||
- Add pytest.patch to fix compatibility with new pytest
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Wed Oct 23 13:02:57 UTC 2024 - Daniel Garcia <daniel.garcia@suse.com>
|
||||
|
||||
- Remove ipython dependency for Leap
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Thu Sep 26 09:27:25 UTC 2024 - Matej Cepl <mcepl@cepl.eu>
|
||||
|
||||
- Split test run into separate build using _multibuild.
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Fri Sep 20 20:29:20 UTC 2024 - Matej Cepl <mcepl@cepl.eu>
|
||||
|
||||
- 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á <mmachova@suse.com>
|
||||
|
||||
- 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 <adrian.glaubitz@suse.com>
|
||||
|
||||
- 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 <steven.kowalik@suse.com>
|
||||
|
||||
- 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 <dmueller@suse.com>
|
||||
|
||||
- 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 <dmueller@suse.com>
|
||||
|
||||
- add sle15_python_module_pythons (jsc#PED-68)
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Thu Apr 13 22:41:09 UTC 2023 - Matej Cepl <mcepl@suse.com>
|
||||
|
||||
- Make calling of %{sle15modernpython} optional.
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Fri Dec 2 17:32:34 UTC 2022 - Yogalakshmi Arunachalam <yarunachalam@suse.com>
|
||||
|
||||
- Update to 1.2.0
|
||||
Merge pull request #56 from alexmojaki/init_tokens
|
||||
Use new asttokens.ASTText
|
||||
|
||||
- Update to 1.1.1
|
||||
tox is breaking weirdly with too much parallelism
|
||||
|
||||
- Update to 1.1.0
|
||||
3.11 in setup.cfg
|
||||
|
||||
- Update to 1.0.0
|
||||
Merge pull request #46 from alexmojaki/checkcache
|
||||
Always check linecache
|
||||
|
||||
- Update to 0.10.0
|
||||
Merge pull request #45 from alexmojaki/reload
|
||||
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
|
||||
* Merge pull request #38 from alexmojaki/pwwang/master
|
||||
Support STORE_ATTR and STORE_SUBSCR
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Sun Mar 27 10:48:50 UTC 2022 - Dirk Müller <dmueller@suse.com>
|
||||
|
||||
- update to 0.8.3:
|
||||
* handle new iphython cell code names
|
||||
* link to futurecoder
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Thu Dec 2 12:42:43 UTC 2021 - Guillaume GARDET <guillaume.gardet@opensuse.org>
|
||||
|
||||
- Skip python 3.6 since python-asttokens dropped it
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Tue Nov 2 13:47:37 UTC 2021 - pgajdos@suse.com
|
||||
|
||||
- version update to 0.8.2
|
||||
* no upstream changelog
|
||||
- %check: use %pyunittest rpm macro
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Wed Dec 2 20:23:30 UTC 2020 - ecsos <ecsos@opensuse.org>
|
||||
|
||||
- Update to 0.5.3
|
||||
- Handle pypy saying the current instruction is an extended arg
|
||||
- Changes from 0.5.2
|
||||
- Convert path to string before checking filename cache
|
||||
- Changes from 0.5.1
|
||||
- Get top level statement containing IPython node
|
||||
- Changes from 0.5.0
|
||||
- Also cache Source objects by contents (lines)
|
||||
- Changes from 0.4.4
|
||||
- Move packaging metadata into setup.cfg
|
||||
- Changes from 0.4.3
|
||||
- Bump to 0.4.3
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Wed Mar 11 09:51:32 PM UTC 2020 - John Vandenberg <jayvdb@gmail.com>
|
||||
|
||||
- Initial spec for v0.4.2
|
95
python-executing.spec
Normal file
95
python-executing.spec
Normal file
@ -0,0 +1,95 @@
|
||||
#
|
||||
# spec file for package python-executing
|
||||
#
|
||||
# Copyright (c) 2025 SUSE LLC
|
||||
#
|
||||
# All modifications and additions to the file contributed by third parties
|
||||
# remain the property of their copyright owners, unless otherwise agreed
|
||||
# upon. The license for this file, and modifications and additions to the
|
||||
# file, is the same license as for the pristine package itself (unless the
|
||||
# license for the pristine package is not an Open Source License, in which
|
||||
# case the license is the MIT License). An "Open Source License" is a
|
||||
# license that conforms to the Open Source Definition (Version 1.9)
|
||||
# published by the Open Source Initiative.
|
||||
|
||||
# Please submit bugfixes or comments via https://bugs.opensuse.org/
|
||||
#
|
||||
|
||||
|
||||
%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%{psuffix}
|
||||
Version: 2.1.0
|
||||
Release: 0
|
||||
Summary: Get the currently executing AST node of a frame, and other information
|
||||
License: MIT
|
||||
URL: https://github.com/alexmojaki/executing
|
||||
Source: https://files.pythonhosted.org/packages/source/e/executing/executing-%{version}.tar.gz
|
||||
# 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
|
||||
# PATCH-FIX-UPSTREAM https://github.com/alexmojaki/executing/pull/94 fix: check for pytest compatibility
|
||||
Patch1: pytest.patch
|
||||
BuildRequires: %{python_module devel}
|
||||
BuildRequires: %{python_module pip}
|
||||
BuildRequires: %{python_module setuptools_scm >= 4.0.0}
|
||||
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
|
||||
%autosetup -p1 -n executing-%{version}
|
||||
|
||||
%build
|
||||
%if %{without test}
|
||||
%pyproject_wheel
|
||||
%endif
|
||||
|
||||
%install
|
||||
%if %{without test}
|
||||
%pyproject_install
|
||||
%python_expand %fdupes %{buildroot}%{$python_sitelib}
|
||||
%endif
|
||||
|
||||
%check
|
||||
%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}/executing
|
||||
%{python_sitelib}/executing-%{version}.dist-info
|
||||
%endif
|
||||
|
||||
%changelog
|
116
support-new-python-3.12.patch
Normal file
116
support-new-python-3.12.patch
Normal file
@ -0,0 +1,116 @@
|
||||
From 0b913873b9db8c157a8dd581e8771242bcb8864b Mon Sep 17 00:00:00 2001
|
||||
From: Frank Hoffmann <15r10nk-git@polarbit.de>
|
||||
Date: Fri, 16 Aug 2024 22:51:32 +0200
|
||||
Subject: [PATCH 1/4] fix: backward compatibility fix for changed source
|
||||
positions in 3.12.5 (#82)
|
||||
|
||||
---
|
||||
executing/_position_node_finder.py | 27 +++++++++++++++++++++++++++
|
||||
1 file changed, 27 insertions(+)
|
||||
|
||||
Index: executing-2.0.1/executing/_position_node_finder.py
|
||||
===================================================================
|
||||
--- executing-2.0.1.orig/executing/_position_node_finder.py
|
||||
+++ executing-2.0.1/executing/_position_node_finder.py
|
||||
@@ -156,6 +156,8 @@ class PositionNodeFinder(object):
|
||||
typ=typ,
|
||||
)
|
||||
|
||||
+ self.result = self.fix_result(self.result, self.instruction(lasti))
|
||||
+
|
||||
self.known_issues(self.result, self.instruction(lasti))
|
||||
|
||||
self.test_for_decorator(self.result, lasti)
|
||||
@@ -213,6 +215,32 @@ class PositionNodeFinder(object):
|
||||
if sys.version_info < (3, 12):
|
||||
index += 4
|
||||
|
||||
+ def fix_result(
|
||||
+ self, node: EnhancedAST, instruction: dis.Instruction
|
||||
+ ) -> EnhancedAST:
|
||||
+ if (
|
||||
+ sys.version_info >= (3, 12, 5)
|
||||
+ and instruction.opname in ("GET_ITER", "FOR_ITER")
|
||||
+ and isinstance(node.parent, ast.For)
|
||||
+ and node is node.parent.iter
|
||||
+ ):
|
||||
+ # node positions have changed in 3.12.5
|
||||
+ # https://github.com/python/cpython/issues/93691
|
||||
+ # `for` calls __iter__ and __next__ during execution, the calling
|
||||
+ # expression of these calls was the ast.For node since cpython 3.11 (see test_iter).
|
||||
+ # cpython 3.12.5 changed this to the `iter` node of the loop, to make tracebacks easier to read.
|
||||
+ # This keeps backward compatibility with older executing versions.
|
||||
+
|
||||
+ # there are also cases like:
|
||||
+ #
|
||||
+ # for a in iter(l): pass
|
||||
+ #
|
||||
+ # where `iter(l)` would be otherwise the resulting node for the `iter()` call and the __iter__ call of the for implementation.
|
||||
+ # keeping the old behaviour makes it possible to distinguish both cases.
|
||||
+
|
||||
+ return node.parent
|
||||
+ return node
|
||||
+
|
||||
def known_issues(self, node: EnhancedAST, instruction: dis.Instruction) -> None:
|
||||
if instruction.opname in ("COMPARE_OP", "IS_OP", "CONTAINS_OP") and isinstance(
|
||||
node, types_cmp_issue
|
||||
Index: executing-2.0.1/.github/workflows/test.yml
|
||||
===================================================================
|
||||
--- executing-2.0.1.orig/.github/workflows/test.yml
|
||||
+++ executing-2.0.1/.github/workflows/test.yml
|
||||
@@ -12,7 +12,7 @@ jobs:
|
||||
runs-on: ubuntu-20.04
|
||||
strategy:
|
||||
matrix:
|
||||
- python-version: [3.5, 3.6, 3.7, 3.8, 3.9, '3.10', 3.11, 3.12-dev, pypy-3.6]
|
||||
+ python-version: [3.8, 3.9, '3.10', 3.11, 3.12-dev]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
Index: executing-2.0.1/setup.cfg
|
||||
===================================================================
|
||||
--- executing-2.0.1.orig/setup.cfg
|
||||
+++ executing-2.0.1/setup.cfg
|
||||
@@ -25,7 +25,7 @@ packages = executing
|
||||
zip_safe = False
|
||||
include_package_data = True
|
||||
setup_requires = setuptools; setuptools_scm[toml]
|
||||
-python_requires = >=3.5
|
||||
+python_requires = >=3.8
|
||||
|
||||
[options.extras_require]
|
||||
tests =
|
||||
Index: executing-2.0.1/tox.ini
|
||||
===================================================================
|
||||
--- executing-2.0.1.orig/tox.ini
|
||||
+++ executing-2.0.1/tox.ini
|
||||
@@ -1,5 +1,5 @@
|
||||
[tox]
|
||||
-envlist = py35,py36,py37,py38,py39,py310,py311,py312,pypy35,pypy36
|
||||
+envlist = py38,py39,py310,py311,py312,pypy35,pypy36
|
||||
|
||||
[testenv]
|
||||
commands =
|
||||
@@ -10,7 +10,7 @@ passenv =
|
||||
ADD_EXECUTING_TESTS
|
||||
EXECUTING_SLOW_TESTS
|
||||
|
||||
-[testenv:generate_small_sample-py{35,36,37,38,39,310,311}]
|
||||
+[testenv:generate_small_sample-py{38,39,310,311,312}]
|
||||
extras = tests
|
||||
deps = pysource-minimize
|
||||
commands =
|
||||
Index: executing-2.0.1/tests/test_main.py
|
||||
===================================================================
|
||||
--- executing-2.0.1.orig/tests/test_main.py
|
||||
+++ executing-2.0.1/tests/test_main.py
|
||||
@@ -802,6 +802,9 @@ class TestFiles:
|
||||
or 'pyparsing.py' in filename
|
||||
or 'enum' in filename
|
||||
)
|
||||
+ or sys.version_info < (3,11) and (
|
||||
+ 'python.py' in filename
|
||||
+ )
|
||||
):
|
||||
continue
|
||||
|
Loading…
x
Reference in New Issue
Block a user