commit: 2c6852e87a5f0fd4b316a3e59bf75f3b1876a1c0 Author: Michał Górny <mgorny <AT> gentoo <DOT> org> AuthorDate: Fri Jul 12 07:44:13 2024 +0000 Commit: Michał Górny <mgorny <AT> gentoo <DOT> org> CommitDate: Fri Jul 12 07:55:10 2024 +0000 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=2c6852e8
dev-python/pure-eval: Enable py3.13 Signed-off-by: Michał Górny <mgorny <AT> gentoo.org> .../pure-eval/files/pure-eval-0.2.2-py313.patch | 63 ++++++++++++++++++++++ dev-python/pure-eval/pure-eval-0.2.2-r1.ebuild | 43 +++++++++++++++ 2 files changed, 106 insertions(+) diff --git a/dev-python/pure-eval/files/pure-eval-0.2.2-py313.patch b/dev-python/pure-eval/files/pure-eval-0.2.2-py313.patch new file mode 100644 index 000000000000..9ec2d680b616 --- /dev/null +++ b/dev-python/pure-eval/files/pure-eval-0.2.2-py313.patch @@ -0,0 +1,63 @@ +From 42e8a1f4a41b60c51619868f543e7b3ee82ac42f Mon Sep 17 00:00:00 2001 +From: Lumir Balhar <[email protected]> +Date: Wed, 15 May 2024 10:14:31 +0200 +Subject: [PATCH] Fix compatibility of check_copy_ast_without_context with Py + 3.13b1 + +Resolves: https://github.com/alexmojaki/pure_eval/issues/16 +--- + tests/test_utils.py | 11 ++++++++++- + 1 file changed, 10 insertions(+), 1 deletion(-) + +diff --git a/tests/test_utils.py b/tests/test_utils.py +index 172f50e..3a9cc9b 100644 +--- a/tests/test_utils.py ++++ b/tests/test_utils.py +@@ -58,7 +58,16 @@ def check_copy_ast_without_context(tree): + dump1 = ast.dump(tree) + dump2 = ast.dump(tree2) + normalised_dump1 = re.sub( +- r", ctx=(Load|Store|Del)\(\)", ++ # Two possible matches: ++ # - first one like ", ctx=…" where ", " should be removed ++ # - second one like "(ctx=…" where "(" should be kept ++ ( ++ r"(" ++ r", ctx=(Load|Store|Del)\(\)" ++ r"|" ++ r"(?<=\()ctx=(Load|Store|Del)\(\)" ++ r")" ++ ), + "", + dump1 + ) +From 89645cfd19d1480d586af50842f0ac264a036fa8 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Miro=20Hron=C4=8Dok?= <[email protected]> +Date: Sun, 9 Jun 2024 21:45:31 +0200 +Subject: [PATCH] Explicitly remove the ctx attribute in + copy_ast_without_context + +Python 3.13.0b2+ defaults to Load when we don't pass ctx +See https://github.com/python/cpython/pull/118871 +--- + pure_eval/utils.py | 7 ++++++- + 1 file changed, 6 insertions(+), 1 deletion(-) + +diff --git a/pure_eval/utils.py b/pure_eval/utils.py +index a8a3730..19ead65 100644 +--- a/pure_eval/utils.py ++++ b/pure_eval/utils.py +@@ -184,7 +184,12 @@ def copy_ast_without_context(x): + if field != 'ctx' + if hasattr(x, field) + } +- return type(x)(**kwargs) ++ a = type(x)(**kwargs) ++ if hasattr(a, 'ctx'): ++ # Python 3.13.0b2+ defaults to Load when we don't pass ctx ++ # https://github.com/python/cpython/pull/118871 ++ del a.ctx ++ return a + elif isinstance(x, list): + return list(map(copy_ast_without_context, x)) + else: diff --git a/dev-python/pure-eval/pure-eval-0.2.2-r1.ebuild b/dev-python/pure-eval/pure-eval-0.2.2-r1.ebuild new file mode 100644 index 000000000000..3268f08fd3f0 --- /dev/null +++ b/dev-python/pure-eval/pure-eval-0.2.2-r1.ebuild @@ -0,0 +1,43 @@ +# Copyright 1999-2024 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI=8 + +DISTUTILS_USE_PEP517=setuptools +PYTHON_COMPAT=( pypy3 python3_{10..13} ) + +inherit distutils-r1 pypi + +DESCRIPTION="Safely evaluate AST nodes without side effects" +HOMEPAGE=" + https://github.com/alexmojaki/pure_eval/ + https://pypi.org/project/pure-eval/ +" + +LICENSE="MIT" +SLOT="0" +KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~loong ~ppc ~ppc64 ~riscv ~s390 ~sparc ~x86 ~arm64-macos ~x64-macos" + +distutils_enable_tests pytest + +PATCHES=( + # https://github.com/alexmojaki/pure_eval/commit/42e8a1f4a41b60c51619868f543e7b3ee82ac42f + # https://github.com/alexmojaki/pure_eval/pull/18 + "${FILESDIR}/${P}-py313.patch" +) + +python_test() { + local EPYTEST_DESELECT=() + + case ${EPYTHON} in + pypy3) + EPYTEST_DESELECT+=( + # https://github.com/alexmojaki/pure_eval/issues/15 + tests/test_getattr_static.py::TestGetattrStatic::test_custom_object_dict + tests/test_utils.py::test_safe_name_samples + ) + ;; + esac + + epytest +}
