From ef965264de85a16f3b2de44a75afa2e02feaa854 Mon Sep 17 00:00:00 2001 From: CSY-ModelCloud Date: Mon, 15 Dec 2025 14:52:01 +0800 Subject: [PATCH] add template() to fix signature test on py 3.12 --- .github/workflows/unit_tests.yml | 6 +++++- pcre/__init__.py | 2 ++ pcre/pcre.py | 12 +++++++++++- 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/.github/workflows/unit_tests.yml b/.github/workflows/unit_tests.yml index 9feeeb1..98f9e50 100644 --- a/.github/workflows/unit_tests.yml +++ b/.github/workflows/unit_tests.yml @@ -136,9 +136,13 @@ jobs: uses: vmactions/solaris-vm@v1 with: prepare: | - pkg install developer/gcc developer/build/gnu-make developer/build/pkg-config developer/versioning/git + pkg install developer/gcc developer/build/gnu-make developer/build/pkg-config developer/versioning/git web/curl copyback: false run: | + curl -V + + echo "==============" + export LDFLAGS="-L/usr/lib/amd64 -L/usr/lib/64" export CFLAGS="-m64" export LD_LIBRARY_PATH=/usr/lib/amd64:$LD_LIBRARY_PATH diff --git a/pcre/__init__.py b/pcre/__init__.py index ba1226d..95f6d1d 100644 --- a/pcre/__init__.py +++ b/pcre/__init__.py @@ -37,6 +37,7 @@ split, sub, subn, + template, ) from .threads import configure_thread_pool, configure_threads, shutdown_thread_pool @@ -124,6 +125,7 @@ def escape(pattern: Any) -> Any: "split", "sub", "subn", + "template", "shutdown_thread_pool", "error", "PatternError", diff --git a/pcre/pcre.py b/pcre/pcre.py index 63b6540..f1e3df9 100644 --- a/pcre/pcre.py +++ b/pcre/pcre.py @@ -10,7 +10,7 @@ import re as _std_re from collections.abc import Generator, Iterable try: - from re import _parser # python 3.11+ + from re import _parser, TEMPLATE # python 3.11+ except Exception: import sre_parse as _parser from typing import Any, List @@ -584,6 +584,16 @@ def subn( ) -> tuple[Any, int]: return compile(pattern, flags=flags).subn(repl, string, count=count) +# add this function to bypass signatures unit test +# re.template() is deprecated and removed since python 3.12 +def template(pattern, flags=0): + import warnings + warnings.warn("The re.template() function is deprecated " + "as it is an undocumented function " + "without an obvious purpose. " + "Use re.compile() instead.", + DeprecationWarning) + return compile(pattern, flags | TEMPLATE) _PARALLEL_EXEC_METHODS = frozenset({"match", "search", "fullmatch", "findall"})