PyPcre 0.2.12__tar.gz → 0.2.14__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. {pypcre-0.2.12 → pypcre-0.2.14}/PKG-INFO +5 -4
  2. {pypcre-0.2.12 → pypcre-0.2.14}/PyPcre.egg-info/PKG-INFO +5 -4
  3. {pypcre-0.2.12 → pypcre-0.2.14}/PyPcre.egg-info/SOURCES.txt +1 -0
  4. {pypcre-0.2.12 → pypcre-0.2.14}/README.md +4 -3
  5. {pypcre-0.2.12 → pypcre-0.2.14}/pcre/__init__.py +2 -0
  6. pypcre-0.2.14/pcre/_stdlib_re.py +28 -0
  7. {pypcre-0.2.12 → pypcre-0.2.14}/pcre/pcre.py +3 -6
  8. {pypcre-0.2.12 → pypcre-0.2.14}/pcre/re_compat.py +2 -4
  9. {pypcre-0.2.12 → pypcre-0.2.14}/pyproject.toml +1 -1
  10. {pypcre-0.2.12 → pypcre-0.2.14}/setup_utils.py +29 -21
  11. {pypcre-0.2.12 → pypcre-0.2.14}/tests/test_api_parity.py +9 -0
  12. {pypcre-0.2.12 → pypcre-0.2.14}/tests/test_core.py +30 -0
  13. {pypcre-0.2.12 → pypcre-0.2.14}/LICENSE +0 -0
  14. {pypcre-0.2.12 → pypcre-0.2.14}/MANIFEST.in +0 -0
  15. {pypcre-0.2.12 → pypcre-0.2.14}/PyPcre.egg-info/dependency_links.txt +0 -0
  16. {pypcre-0.2.12 → pypcre-0.2.14}/PyPcre.egg-info/top_level.txt +0 -0
  17. {pypcre-0.2.12 → pypcre-0.2.14}/pcre/cache.py +0 -0
  18. {pypcre-0.2.12 → pypcre-0.2.14}/pcre/error.py +0 -0
  19. {pypcre-0.2.12 → pypcre-0.2.14}/pcre/flags.py +0 -0
  20. {pypcre-0.2.12 → pypcre-0.2.14}/pcre/threads.py +0 -0
  21. {pypcre-0.2.12 → pypcre-0.2.14}/pcre_ext/atomic_compat.h +0 -0
  22. {pypcre-0.2.12 → pypcre-0.2.14}/pcre_ext/cache.c +0 -0
  23. {pypcre-0.2.12 → pypcre-0.2.14}/pcre_ext/error.c +0 -0
  24. {pypcre-0.2.12 → pypcre-0.2.14}/pcre_ext/flag.c +0 -0
  25. {pypcre-0.2.12 → pypcre-0.2.14}/pcre_ext/jit_support.c +0 -0
  26. {pypcre-0.2.12 → pypcre-0.2.14}/pcre_ext/memory.c +0 -0
  27. {pypcre-0.2.12 → pypcre-0.2.14}/pcre_ext/pattern_cache.c +0 -0
  28. {pypcre-0.2.12 → pypcre-0.2.14}/pcre_ext/pcre2.c +0 -0
  29. {pypcre-0.2.12 → pypcre-0.2.14}/pcre_ext/pcre2.h +0 -0
  30. {pypcre-0.2.12 → pypcre-0.2.14}/pcre_ext/pcre2_module.h +0 -0
  31. {pypcre-0.2.12 → pypcre-0.2.14}/pcre_ext/string_helpers.c +0 -0
  32. {pypcre-0.2.12 → pypcre-0.2.14}/pcre_ext/util.c +0 -0
  33. {pypcre-0.2.12 → pypcre-0.2.14}/setup.cfg +0 -0
  34. {pypcre-0.2.12 → pypcre-0.2.14}/setup.py +0 -0
  35. {pypcre-0.2.12 → pypcre-0.2.14}/tests/test_accuracy.py +0 -0
  36. {pypcre-0.2.12 → pypcre-0.2.14}/tests/test_basic.py +0 -0
  37. {pypcre-0.2.12 → pypcre-0.2.14}/tests/test_bench_string.py +0 -0
  38. {pypcre-0.2.12 → pypcre-0.2.14}/tests/test_benchmark.py +0 -0
  39. {pypcre-0.2.12 → pypcre-0.2.14}/tests/test_bytes.py +0 -0
  40. {pypcre-0.2.12 → pypcre-0.2.14}/tests/test_cache.py +0 -0
  41. {pypcre-0.2.12 → pypcre-0.2.14}/tests/test_clobber.py +0 -0
  42. {pypcre-0.2.12 → pypcre-0.2.14}/tests/test_clobber_thread.py +0 -0
  43. {pypcre-0.2.12 → pypcre-0.2.14}/tests/test_errors.py +0 -0
  44. {pypcre-0.2.12 → pypcre-0.2.14}/tests/test_flags.py +0 -0
  45. {pypcre-0.2.12 → pypcre-0.2.14}/tests/test_jit.py +0 -0
  46. {pypcre-0.2.12 → pypcre-0.2.14}/tests/test_memory.py +0 -0
  47. {pypcre-0.2.12 → pypcre-0.2.14}/tests/test_module.py +0 -0
  48. {pypcre-0.2.12 → pypcre-0.2.14}/tests/test_pattern.py +0 -0
  49. {pypcre-0.2.12 → pypcre-0.2.14}/tests/test_setup_utils_multiarch.py +0 -0
  50. {pypcre-0.2.12 → pypcre-0.2.14}/tests/test_simd.py +0 -0
  51. {pypcre-0.2.12 → pypcre-0.2.14}/tests/test_threaded_backend.py +0 -0
  52. {pypcre-0.2.12 → pypcre-0.2.14}/tests/test_transformers_regex.py +0 -0
  53. {pypcre-0.2.12 → pypcre-0.2.14}/tests/test_utf8.py +0 -0
  54. {pypcre-0.2.12 → pypcre-0.2.14}/tests/test_version.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: PyPcre
3
- Version: 0.2.12
3
+ Version: 0.2.14
4
4
  Summary: Modern, GIL-friendly, Fast Python bindings for PCRE2 with auto caching and JIT of compiled patterns.
5
5
  Author-email: ModelCloud <qubitium@modelcloud.ai>
6
6
  License-Expression: Apache-2.0
@@ -43,11 +43,12 @@ Modern `nogil` Python bindings for the Pcre2 library with `stdlib.re` api compat
43
43
 
44
44
 
45
45
  ## Latest News
46
+ * 03/21/2026 [0.2.14](https://github.com/ModelCloud/PyPcre/releases/tag/v0.2.4): Python 3.14 compat
46
47
  * 03/02/2026 [0.2.11](https://github.com/ModelCloud/PyPcre/releases/tag/v0.2.11): Auto-detect `Visual Studio` for `Windows` env during install/compile.
47
48
  * 02/24/2026 [0.2.10](https://github.com/ModelCloud/PyPcre/releases/tag/v0.2.10): Allow VisualStudio (VS) compiler version check override via env var.
48
49
  * 12/15/2025 [0.2.8](https://github.com/ModelCloud/PyPcre/releases/tag/v0.2.8): Fixed multi-arch Linux os compatibility where both x86_64 and i386 libs of pcre2 are installed.
49
50
  * 10/20/2025 [0.2.4](https://github.com/ModelCloud/PyPcre/releases/tag/v0.2.4): Removed dependency on system having python3-dev packge. python.h will be optimistically downloaded from python.org when needed.
50
- * 10/12/2025 [0.2.3](https://github.com/ModelCloud/PyPcre/releases/tag/v0.2.3): 🤗 Full `GIL=0` compliance for Python >= 3.13T. Reduced cache thread contention. Improved performance for all api. Expanded ci testing coverage. FreeBSD, Solaris, and Windows compatibility validated.
51
+ * 10/12/2025 [0.2.3](https://github.com/ModelCloud/PyPcre/releases/tag/v0.2.3): 🤗 Full `GIL=0` compliance for Python >= 3.13T. Reduced cache thread contention. Improved performance for all api. Expanded ci testing coverage. FreeBSD, Solaris and Windows compatibility validated.
51
52
  * 10/09/2025 [0.1.0](https://github.com/ModelCloud/PyPcre/releases/tag/v0.1.0): 🎉 First release. Thread safe, auto JIT, auto pattern caching and optimistic linking to system library for fast install.
52
53
 
53
54
  ## Why PyPcre:
@@ -70,7 +71,7 @@ The package prioritizes linking against the `libpcre2-8` shared library in syste
70
71
 
71
72
  ## Platform Support (Validated):
72
73
 
73
- `Linux`, `MacOS`, `Windows`, `WSL`, `FreeBSD`, `Solaris`
74
+ `Linux`, `MacOS`, `Windows`, `WSL`, `FreeBSD`
74
75
 
75
76
 
76
77
  ## Usage
@@ -303,7 +304,7 @@ When `pkg-config` is available the build will automatically pick up the
303
304
  required include and link flags via `pkg-config --cflags/--libs libpcre2-8`.
304
305
  Without `pkg-config`, the build script scans common installation prefixes for
305
306
  Linux distributions (Debian, Ubuntu, Fedora/RHEL/CentOS, openSUSE, Alpine),
306
- FreeBSD, macOS (including Homebrew), and Solaris to locate the headers and
307
+ FreeBSD and macOS (including Homebrew) to locate the headers and
307
308
  libraries.
308
309
 
309
310
  If your system ships `libpcre2-8` under `/usr` but you also maintain a
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: PyPcre
3
- Version: 0.2.12
3
+ Version: 0.2.14
4
4
  Summary: Modern, GIL-friendly, Fast Python bindings for PCRE2 with auto caching and JIT of compiled patterns.
5
5
  Author-email: ModelCloud <qubitium@modelcloud.ai>
6
6
  License-Expression: Apache-2.0
@@ -43,11 +43,12 @@ Modern `nogil` Python bindings for the Pcre2 library with `stdlib.re` api compat
43
43
 
44
44
 
45
45
  ## Latest News
46
+ * 03/21/2026 [0.2.14](https://github.com/ModelCloud/PyPcre/releases/tag/v0.2.4): Python 3.14 compat
46
47
  * 03/02/2026 [0.2.11](https://github.com/ModelCloud/PyPcre/releases/tag/v0.2.11): Auto-detect `Visual Studio` for `Windows` env during install/compile.
47
48
  * 02/24/2026 [0.2.10](https://github.com/ModelCloud/PyPcre/releases/tag/v0.2.10): Allow VisualStudio (VS) compiler version check override via env var.
48
49
  * 12/15/2025 [0.2.8](https://github.com/ModelCloud/PyPcre/releases/tag/v0.2.8): Fixed multi-arch Linux os compatibility where both x86_64 and i386 libs of pcre2 are installed.
49
50
  * 10/20/2025 [0.2.4](https://github.com/ModelCloud/PyPcre/releases/tag/v0.2.4): Removed dependency on system having python3-dev packge. python.h will be optimistically downloaded from python.org when needed.
50
- * 10/12/2025 [0.2.3](https://github.com/ModelCloud/PyPcre/releases/tag/v0.2.3): 🤗 Full `GIL=0` compliance for Python >= 3.13T. Reduced cache thread contention. Improved performance for all api. Expanded ci testing coverage. FreeBSD, Solaris, and Windows compatibility validated.
51
+ * 10/12/2025 [0.2.3](https://github.com/ModelCloud/PyPcre/releases/tag/v0.2.3): 🤗 Full `GIL=0` compliance for Python >= 3.13T. Reduced cache thread contention. Improved performance for all api. Expanded ci testing coverage. FreeBSD, Solaris and Windows compatibility validated.
51
52
  * 10/09/2025 [0.1.0](https://github.com/ModelCloud/PyPcre/releases/tag/v0.1.0): 🎉 First release. Thread safe, auto JIT, auto pattern caching and optimistic linking to system library for fast install.
52
53
 
53
54
  ## Why PyPcre:
@@ -70,7 +71,7 @@ The package prioritizes linking against the `libpcre2-8` shared library in syste
70
71
 
71
72
  ## Platform Support (Validated):
72
73
 
73
- `Linux`, `MacOS`, `Windows`, `WSL`, `FreeBSD`, `Solaris`
74
+ `Linux`, `MacOS`, `Windows`, `WSL`, `FreeBSD`
74
75
 
75
76
 
76
77
  ## Usage
@@ -303,7 +304,7 @@ When `pkg-config` is available the build will automatically pick up the
303
304
  required include and link flags via `pkg-config --cflags/--libs libpcre2-8`.
304
305
  Without `pkg-config`, the build script scans common installation prefixes for
305
306
  Linux distributions (Debian, Ubuntu, Fedora/RHEL/CentOS, openSUSE, Alpine),
306
- FreeBSD, macOS (including Homebrew), and Solaris to locate the headers and
307
+ FreeBSD and macOS (including Homebrew) to locate the headers and
307
308
  libraries.
308
309
 
309
310
  If your system ships `libpcre2-8` under `/usr` but you also maintain a
@@ -9,6 +9,7 @@ PyPcre.egg-info/SOURCES.txt
9
9
  PyPcre.egg-info/dependency_links.txt
10
10
  PyPcre.egg-info/top_level.txt
11
11
  pcre/__init__.py
12
+ pcre/_stdlib_re.py
12
13
  pcre/cache.py
13
14
  pcre/error.py
14
15
  pcre/flags.py
@@ -20,11 +20,12 @@ Modern `nogil` Python bindings for the Pcre2 library with `stdlib.re` api compat
20
20
 
21
21
 
22
22
  ## Latest News
23
+ * 03/21/2026 [0.2.14](https://github.com/ModelCloud/PyPcre/releases/tag/v0.2.4): Python 3.14 compat
23
24
  * 03/02/2026 [0.2.11](https://github.com/ModelCloud/PyPcre/releases/tag/v0.2.11): Auto-detect `Visual Studio` for `Windows` env during install/compile.
24
25
  * 02/24/2026 [0.2.10](https://github.com/ModelCloud/PyPcre/releases/tag/v0.2.10): Allow VisualStudio (VS) compiler version check override via env var.
25
26
  * 12/15/2025 [0.2.8](https://github.com/ModelCloud/PyPcre/releases/tag/v0.2.8): Fixed multi-arch Linux os compatibility where both x86_64 and i386 libs of pcre2 are installed.
26
27
  * 10/20/2025 [0.2.4](https://github.com/ModelCloud/PyPcre/releases/tag/v0.2.4): Removed dependency on system having python3-dev packge. python.h will be optimistically downloaded from python.org when needed.
27
- * 10/12/2025 [0.2.3](https://github.com/ModelCloud/PyPcre/releases/tag/v0.2.3): 🤗 Full `GIL=0` compliance for Python >= 3.13T. Reduced cache thread contention. Improved performance for all api. Expanded ci testing coverage. FreeBSD, Solaris, and Windows compatibility validated.
28
+ * 10/12/2025 [0.2.3](https://github.com/ModelCloud/PyPcre/releases/tag/v0.2.3): 🤗 Full `GIL=0` compliance for Python >= 3.13T. Reduced cache thread contention. Improved performance for all api. Expanded ci testing coverage. FreeBSD, Solaris and Windows compatibility validated.
28
29
  * 10/09/2025 [0.1.0](https://github.com/ModelCloud/PyPcre/releases/tag/v0.1.0): 🎉 First release. Thread safe, auto JIT, auto pattern caching and optimistic linking to system library for fast install.
29
30
 
30
31
  ## Why PyPcre:
@@ -47,7 +48,7 @@ The package prioritizes linking against the `libpcre2-8` shared library in syste
47
48
 
48
49
  ## Platform Support (Validated):
49
50
 
50
- `Linux`, `MacOS`, `Windows`, `WSL`, `FreeBSD`, `Solaris`
51
+ `Linux`, `MacOS`, `Windows`, `WSL`, `FreeBSD`
51
52
 
52
53
 
53
54
  ## Usage
@@ -280,7 +281,7 @@ When `pkg-config` is available the build will automatically pick up the
280
281
  required include and link flags via `pkg-config --cflags/--libs libpcre2-8`.
281
282
  Without `pkg-config`, the build script scans common installation prefixes for
282
283
  Linux distributions (Debian, Ubuntu, Fedora/RHEL/CentOS, openSUSE, Alpine),
283
- FreeBSD, macOS (including Homebrew), and Solaris to locate the headers and
284
+ FreeBSD and macOS (including Homebrew) to locate the headers and
284
285
  libraries.
285
286
 
286
287
  If your system ships `libpcre2-8` under `/usr` but you also maintain a
@@ -96,6 +96,8 @@ _FLAG_COMPAT_ALIASES = {
96
96
  "A": Flag.NO_UTF | Flag.NO_UCP,
97
97
  "UNICODE": _FLAG_ZERO,
98
98
  "U": _FLAG_ZERO,
99
+ "TEMPLATE": _FLAG_ZERO,
100
+ "T": _FLAG_ZERO,
99
101
  }
100
102
 
101
103
  for _alias, _flag in _FLAG_COMPAT_ALIASES.items():
@@ -0,0 +1,28 @@
1
+ """Compatibility helpers for private stdlib :mod:`re` internals."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import re as _std_re
6
+ import warnings
7
+
8
+
9
+ def _load_parser():
10
+ parser = getattr(_std_re, "_parser", None)
11
+ if parser is not None:
12
+ return parser
13
+
14
+ with warnings.catch_warnings():
15
+ warnings.simplefilter("ignore", DeprecationWarning)
16
+ import sre_parse as parser
17
+
18
+ return parser
19
+
20
+
21
+ _parser = _load_parser()
22
+
23
+ RE_TEMPLATE = getattr(_std_re, "TEMPLATE", 0)
24
+ RE_TEMPLATE_FLAG: int = int(getattr(_std_re, "TEMPLATE", 0))
25
+ RE_UNICODE_FLAG: int = int(getattr(_std_re, "UNICODE", 0))
26
+
27
+
28
+ __all__ = ["_parser", "RE_TEMPLATE", "RE_TEMPLATE_FLAG", "RE_UNICODE_FLAG"]
@@ -9,14 +9,11 @@ from __future__ import annotations
9
9
 
10
10
  import re as _std_re
11
11
  from collections.abc import Generator, Iterable
12
- try:
13
- from re import _parser, TEMPLATE # python 3.11+
14
- except Exception:
15
- import sre_parse as _parser
16
12
  from typing import Any, List
17
13
 
18
14
  import pcre_ext_c as _pcre2
19
15
 
16
+ from ._stdlib_re import RE_TEMPLATE, RE_TEMPLATE_FLAG, RE_UNICODE_FLAG, _parser
20
17
  from .cache import cached_compile
21
18
  from .cache import clear_cache as _clear_cache
22
19
  from .flags import Flag, strip_py_only_flags
@@ -128,7 +125,7 @@ def _apply_default_unicode_flags(pattern: Any, flags: int) -> int:
128
125
 
129
126
 
130
127
  def _coerce_stdlib_regexflag(flag: _std_re.RegexFlag) -> int:
131
- unsupported_bits = int(flag) & ~_STD_RE_FLAG_MASK
128
+ unsupported_bits = int(flag) & ~(_STD_RE_FLAG_MASK | RE_TEMPLATE_FLAG | RE_UNICODE_FLAG)
132
129
  if unsupported_bits:
133
130
  unsupported = _std_re.RegexFlag(unsupported_bits)
134
131
  raise ValueError(
@@ -618,7 +615,7 @@ def template(pattern, flags=0):
618
615
  "without an obvious purpose. "
619
616
  "Use re.compile() instead.",
620
617
  DeprecationWarning)
621
- return compile(pattern, flags | TEMPLATE)
618
+ return compile(pattern, flags | RE_TEMPLATE)
622
619
 
623
620
  _PARALLEL_EXEC_METHODS = frozenset({"match", "search", "fullmatch", "findall"})
624
621
 
@@ -9,14 +9,12 @@ from __future__ import annotations
9
9
 
10
10
  import operator
11
11
  import re as _std_re
12
- try:
13
- from re import _parser # python 3.11+
14
- except Exception:
15
- import sre_parse as _parser
16
12
  from typing import Any, List
17
13
 
18
14
  import pcre_ext_c as _pcre2
19
15
 
16
+ from ._stdlib_re import _parser
17
+
20
18
 
21
19
  _CRawMatch = _pcre2.Match
22
20
 
@@ -9,7 +9,7 @@ build-backend = "setuptools.build_meta"
9
9
 
10
10
  [project]
11
11
  name = "PyPcre"
12
- version = "0.2.12"
12
+ version = "0.2.14"
13
13
  description = "Modern, GIL-friendly, Fast Python bindings for PCRE2 with auto caching and JIT of compiled patterns."
14
14
  readme = "README.md"
15
15
  requires-python = ">=3.9"
@@ -481,7 +481,11 @@ def _find_vswhere():
481
481
  def _detect_vs_generator():
482
482
  vswhere = _find_vswhere()
483
483
  if not vswhere:
484
- return None
484
+ raise RuntimeError(
485
+ "unable to find vswhere.exe\n"
486
+ "Please install Visual Studio Build Tools:\n"
487
+ f"{VS_DOWNLOAD_URL}"
488
+ )
485
489
 
486
490
  result = subprocess.run(
487
491
  [
@@ -497,32 +501,42 @@ def _detect_vs_generator():
497
501
  )
498
502
 
499
503
  if result.returncode != 0:
500
- return None
504
+ raise RuntimeError(
505
+ f"vswhere failed.\n"
506
+ f"exit code: {result.returncode}\n"
507
+ f"stdout: {result.stdout.strip()}\n"
508
+ f"stderr: {result.stderr.strip()}\n"
509
+ )
510
+
511
+ try:
512
+ data = json.loads(result.stdout or "[]")
513
+ except json.JSONDecodeError as e:
514
+ raise RuntimeError(
515
+ f"unable to parse vswhere output. Output: {result.stdout}"
516
+ ) from e
501
517
 
502
- data = json.loads(result.stdout or "[]")
503
518
  if not data:
504
- return None
519
+ raise RuntimeError(f"vswhere cannot find a valid VS installation: {result.stdout}")
505
520
 
506
521
  info = data[0]
507
522
 
508
523
  ver = info.get("installationVersion", "")
509
524
  major = ver.split(".")[0]
510
525
 
511
- year = info.get("catalog", {}).get("productLineVersion")
512
-
513
- if not year:
514
- year_map = {
515
- "15": "2017",
516
- "16": "2019",
517
- "17": "2022",
518
- "18": "2026",
519
- }
520
- year = year_map.get(major)
526
+ year_map = {
527
+ "15": "2017",
528
+ "16": "2019",
529
+ "17": "2022",
530
+ "18": "2026",
531
+ }
532
+ year = year_map.get(str(major))
521
533
 
522
534
  if year:
523
535
  return f"Visual Studio {major} {year}"
524
536
 
525
- return f"Visual Studio {major}"
537
+ raise RuntimeError(
538
+ f"Unknown Visual Studio version: installationVersion={ver}, major={major}, year={year}. vswhere result: {result.stdout}"
539
+ )
526
540
 
527
541
 
528
542
  def _prepare_pcre2_source() -> tuple[list[str], list[str], list[str]]:
@@ -635,12 +649,6 @@ def _prepare_pcre2_source() -> tuple[list[str], list[str], list[str]]:
635
649
  # On Windows, force MSVC and the /MD runtime. Never let CMake pick MinGW.
636
650
  if _is_windows_platform():
637
651
  vs_gen = os.environ.get("CMAKE_GENERATOR", _detect_vs_generator())
638
- if not vs_gen:
639
- raise RuntimeError(
640
- "Visual Studio not found.\n"
641
- "Please install Visual Studio Build Tools:\n"
642
- f"{VS_DOWNLOAD_URL}"
643
- )
644
652
  cmake_args += [
645
653
  "-G", vs_gen,
646
654
  "-A", "x64",
@@ -51,6 +51,8 @@ def test_stdlib_style_flag_aliases():
51
51
  assert pcre.A == ascii_alias
52
52
  assert pcre.UNICODE == 0
53
53
  assert pcre.U == 0
54
+ assert pcre.TEMPLATE == 0
55
+ assert pcre.T == 0
54
56
 
55
57
 
56
58
  def test_specific_compile_error_exposes_dedicated_exception():
@@ -83,6 +85,13 @@ def test_compile_accepts_stdlib_regex_flags():
83
85
  assert combo.flags & Flag.MULTILINE
84
86
 
85
87
 
88
+ def test_compile_accepts_noop_stdlib_regex_flags():
89
+ compiled = pcre.compile(r"pattern", flags=re.RegexFlag.UNICODE)
90
+ assert isinstance(compiled, pcre.Pattern)
91
+ assert compiled.flags & Flag.UTF
92
+ assert compiled.flags & Flag.UCP
93
+
94
+
86
95
  def test_compile_rejects_incompatible_stdlib_regex_flags():
87
96
  with pytest.raises(ValueError):
88
97
  pcre.compile(r"pattern", flags=re.RegexFlag.DEBUG)
@@ -1,5 +1,6 @@
1
1
  import types
2
2
  from collections import OrderedDict
3
+ import re
3
4
 
4
5
  import pytest
5
6
  from pcre import Flag
@@ -288,6 +289,35 @@ def test_compile_rejects_non_int_iterable_flags():
288
289
  core.compile("expr", flags=("not", "ints"))
289
290
 
290
291
 
292
+ def test_template_delegates_to_compile_without_template_bits(monkeypatch):
293
+ captured = {}
294
+
295
+ def fake_cached(pattern, flags, wrapper, *, jit):
296
+ captured["flags"] = flags
297
+ fake_cpattern = types.SimpleNamespace(
298
+ pattern=pattern,
299
+ groupindex={},
300
+ flags=flags,
301
+ match=MethodRecorder("match"),
302
+ search=MethodRecorder("search"),
303
+ fullmatch=MethodRecorder("fullmatch"),
304
+ jit=jit,
305
+ )
306
+ return wrapper(fake_cpattern)
307
+
308
+ monkeypatch.setattr(core, "cached_compile", fake_cached)
309
+ monkeypatch.setattr(core, "RE_TEMPLATE", re.RegexFlag.UNICODE)
310
+
311
+ with pytest.warns(DeprecationWarning):
312
+ compiled = core.template("expr")
313
+
314
+ expected_flags = strip_py_only_flags(
315
+ core._apply_default_unicode_flags("expr", 0)
316
+ )
317
+ assert captured["flags"] == expected_flags
318
+ assert compiled.flags == expected_flags
319
+
320
+
291
321
  def test_pattern_match_handles_optional_end():
292
322
  match_method = MethodRecorder(FakeMatch((0, 3), group0="matched"))
293
323
  fake_cpattern = types.SimpleNamespace(
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes