From 4cf05de26efa976b338458befffa4e9797f7458b Mon Sep 17 00:00:00 2001 From: Maxwell G Date: Tue, 26 Aug 2025 16:57:51 -0500 Subject: [PATCH 1/2] tests: fix pathlib.PurePosixPath repr on py3.14 ``` fish for i in python3.{9,10,11,12,13,14} echo -n "$i " $i -c 'import pathlib; print(repr(pathlib.PurePosixPath))' end ``` ``` python3.9 python3.10 python3.11 python3.12 python3.13 python3.14 ``` --- tests/test_utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_utils.py b/tests/test_utils.py index 768bd83..08809e2 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -124,7 +124,7 @@ def test_printr(obj, expects, capsys): assert re.match(expects, stdout[0]) -if sys.version_info >= (3, 13): +if sys.version_info[:2] == (3, 13): pure_posix_path_expected = "" else: pure_posix_path_expected = "" From 9fa73b35d9920ff8216fad79ffee20ee815d56ac Mon Sep 17 00:00:00 2001 From: Maxwell G Date: Tue, 26 Aug 2025 17:04:47 -0500 Subject: [PATCH 2/2] words: fix alphabet_sort exception handling for py3.14 As of https://github.com/python/cpython/pull/121395, the format of the list.index exception has changed and parsing it like this no longer works. Relying on implementation details like this is always risky, so this solution should be more future-proof. --- domdf_python_tools/words.py | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/domdf_python_tools/words.py b/domdf_python_tools/words.py index d8bc36c..b26693a 100644 --- a/domdf_python_tools/words.py +++ b/domdf_python_tools/words.py @@ -171,14 +171,13 @@ def alpha_sort( alphabet_ = list(alphabet) - try: - return sorted(iterable, key=lambda attr: [alphabet_.index(letter) for letter in attr], reverse=reverse) - except ValueError as e: - m = re.match(r"'(.*)' is not in list", str(e)) - if m: - raise ValueError(f"The character {m.group(1)!r} was not found in the alphabet.") from None - else: # pragma: no cover - raise e + def _alphabet_index(letter: str) -> int: + try: + return alphabet_.index(letter) + except ValueError: + raise ValueError(f"The character {letter!r} was not found in the alphabet.") from None + + return sorted(iterable, key=lambda attr: [_alphabet_index(letter) for letter in attr], reverse=reverse) class Font(Dict[str, str]):