From 7f27bebe077a892575646865bcc59136bdf45ac06964c0958b700b7c11585ff9 Mon Sep 17 00:00:00 2001 From: Dominik Heidler Date: Mon, 17 Mar 2025 12:53:37 +0000 Subject: [PATCH] - Add fix_re_sub_test_on_python3.13.patch to fix re_sub test OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/micropython?expand=0&rev=38 --- fix_re_sub_test_on_python3.13.patch | 46 +++++++++++++++++++++++++++++ micropython.changes | 5 ++++ micropython.spec | 1 + 3 files changed, 52 insertions(+) create mode 100644 fix_re_sub_test_on_python3.13.patch diff --git a/fix_re_sub_test_on_python3.13.patch b/fix_re_sub_test_on_python3.13.patch new file mode 100644 index 0000000..bb05c7b --- /dev/null +++ b/fix_re_sub_test_on_python3.13.patch @@ -0,0 +1,46 @@ +From e73cf71a246ee456aac0f4d16167e0856846db6b Mon Sep 17 00:00:00 2001 +From: Alessandro Gatti +Date: Sat, 4 Jan 2025 15:00:28 +0100 +Subject: [PATCH] tests/extmod/re_sub.py: Fix test execution on Python 3.13. + +This commit fixes a test failure for `extmod/re_sub.py` where the code, +whilst being correct, would not make the test pass due to a newer +Python version than expected. + +On Python 3.13, running `tests/extmod/re_sub.py` would yield a +deprecation warning about `re.sub` not providing the match count as a +keyword parameter. This warning would be embedded in the expected test +result and thus the test would always fail. + +Co-authored-by: stijn +Signed-off-by: Alessandro Gatti +--- + tests/extmod/re_sub.py | 8 +++++++- + 1 file changed, 7 insertions(+), 1 deletion(-) + +diff --git a/tests/extmod/re_sub.py b/tests/extmod/re_sub.py +index 2c7c6c10f1a49..ecaa66d83d8a7 100644 +--- a/tests/extmod/re_sub.py ++++ b/tests/extmod/re_sub.py +@@ -10,6 +10,8 @@ + print("SKIP") + raise SystemExit + ++import sys ++ + + def multiply(m): + return str(int(m.group(0)) * 2) +@@ -47,7 +49,11 @@ def A(): + print(re.sub("a", "b", "c")) + + # with maximum substitution count specified +-print(re.sub("a", "b", "1a2a3a", 2)) ++if sys.implementation.name != "micropython": ++ # On CPython 3.13 and later the substitution count must be a keyword argument. ++ print(re.sub("a", "b", "1a2a3a", count=2)) ++else: ++ print(re.sub("a", "b", "1a2a3a", 2)) + + # invalid group + try: diff --git a/micropython.changes b/micropython.changes index 123c2c9..7d8fb74 100644 --- a/micropython.changes +++ b/micropython.changes @@ -1,3 +1,8 @@ +------------------------------------------------------------------- +Mon Mar 17 12:24:36 UTC 2025 - Dominik Heidler + +- Add fix_re_sub_test_on_python3.13.patch to fix re_sub test + ------------------------------------------------------------------- Tue Feb 18 11:48:17 UTC 2025 - Dominik Heidler diff --git a/micropython.spec b/micropython.spec index e7c4a39..1fbc170 100644 --- a/micropython.spec +++ b/micropython.spec @@ -26,6 +26,7 @@ Summary: Implementation of Python 3 with very low memory footprint License: MIT URL: https://micropython.org/ Source: https://micropython.org/resources/source/%{name}-%{version}.tar.xz +Patch1: fix_re_sub_test_on_python3.13.patch BuildRequires: openssl BuildRequires: pkgconfig BuildRequires: python3