PyPcre 0.2.2__tar.gz → 0.2.3__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.
- {pypcre-0.2.2 → pypcre-0.2.3}/PKG-INFO +26 -10
- {pypcre-0.2.2 → pypcre-0.2.3}/PyPcre.egg-info/PKG-INFO +26 -10
- {pypcre-0.2.2 → pypcre-0.2.3}/README.md +25 -9
- {pypcre-0.2.2 → pypcre-0.2.3}/pcre/__init__.py +24 -2
- {pypcre-0.2.2 → pypcre-0.2.3}/pcre/pcre.py +0 -6
- {pypcre-0.2.2 → pypcre-0.2.3}/pyproject.toml +1 -1
- {pypcre-0.2.2 → pypcre-0.2.3}/tests/test_api_parity.py +41 -0
- {pypcre-0.2.2 → pypcre-0.2.3}/tests/test_clobber.py +0 -3
- {pypcre-0.2.2 → pypcre-0.2.3}/tests/test_module.py +0 -4
- {pypcre-0.2.2 → pypcre-0.2.3}/LICENSE +0 -0
- {pypcre-0.2.2 → pypcre-0.2.3}/MANIFEST.in +0 -0
- {pypcre-0.2.2 → pypcre-0.2.3}/PyPcre.egg-info/SOURCES.txt +0 -0
- {pypcre-0.2.2 → pypcre-0.2.3}/PyPcre.egg-info/dependency_links.txt +0 -0
- {pypcre-0.2.2 → pypcre-0.2.3}/PyPcre.egg-info/top_level.txt +0 -0
- {pypcre-0.2.2 → pypcre-0.2.3}/pcre/cache.py +0 -0
- {pypcre-0.2.2 → pypcre-0.2.3}/pcre/error.py +0 -0
- {pypcre-0.2.2 → pypcre-0.2.3}/pcre/flags.py +0 -0
- {pypcre-0.2.2 → pypcre-0.2.3}/pcre/re_compat.py +0 -0
- {pypcre-0.2.2 → pypcre-0.2.3}/pcre/threads.py +0 -0
- {pypcre-0.2.2 → pypcre-0.2.3}/pcre_ext/atomic_compat.h +0 -0
- {pypcre-0.2.2 → pypcre-0.2.3}/pcre_ext/cache.c +0 -0
- {pypcre-0.2.2 → pypcre-0.2.3}/pcre_ext/error.c +0 -0
- {pypcre-0.2.2 → pypcre-0.2.3}/pcre_ext/flag.c +0 -0
- {pypcre-0.2.2 → pypcre-0.2.3}/pcre_ext/memory.c +0 -0
- {pypcre-0.2.2 → pypcre-0.2.3}/pcre_ext/pcre2.c +0 -0
- {pypcre-0.2.2 → pypcre-0.2.3}/pcre_ext/pcre2.h +0 -0
- {pypcre-0.2.2 → pypcre-0.2.3}/pcre_ext/pcre2_module.h +0 -0
- {pypcre-0.2.2 → pypcre-0.2.3}/pcre_ext/util.c +0 -0
- {pypcre-0.2.2 → pypcre-0.2.3}/setup.cfg +0 -0
- {pypcre-0.2.2 → pypcre-0.2.3}/setup.py +0 -0
- {pypcre-0.2.2 → pypcre-0.2.3}/setup_utils.py +0 -0
- {pypcre-0.2.2 → pypcre-0.2.3}/tests/test_accuracy.py +0 -0
- {pypcre-0.2.2 → pypcre-0.2.3}/tests/test_basic.py +0 -0
- {pypcre-0.2.2 → pypcre-0.2.3}/tests/test_bench_string.py +0 -0
- {pypcre-0.2.2 → pypcre-0.2.3}/tests/test_benchmark.py +0 -0
- {pypcre-0.2.2 → pypcre-0.2.3}/tests/test_bytes.py +0 -0
- {pypcre-0.2.2 → pypcre-0.2.3}/tests/test_cache.py +0 -0
- {pypcre-0.2.2 → pypcre-0.2.3}/tests/test_clobber_thread.py +0 -0
- {pypcre-0.2.2 → pypcre-0.2.3}/tests/test_core.py +0 -0
- {pypcre-0.2.2 → pypcre-0.2.3}/tests/test_errors.py +0 -0
- {pypcre-0.2.2 → pypcre-0.2.3}/tests/test_flags.py +0 -0
- {pypcre-0.2.2 → pypcre-0.2.3}/tests/test_jit.py +0 -0
- {pypcre-0.2.2 → pypcre-0.2.3}/tests/test_memory.py +0 -0
- {pypcre-0.2.2 → pypcre-0.2.3}/tests/test_pattern.py +0 -0
- {pypcre-0.2.2 → pypcre-0.2.3}/tests/test_simd.py +0 -0
- {pypcre-0.2.2 → pypcre-0.2.3}/tests/test_threaded_backend.py +0 -0
- {pypcre-0.2.2 → pypcre-0.2.3}/tests/test_transformers_regex.py +0 -0
- {pypcre-0.2.2 → pypcre-0.2.3}/tests/test_utf8.py +0 -0
- {pypcre-0.2.2 → pypcre-0.2.3}/tests/test_version.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: PyPcre
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.3
|
|
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
|
|
@@ -32,7 +32,7 @@ Dynamic: license-file
|
|
|
32
32
|
|
|
33
33
|
# PyPcre (Python Pcre2 Binding)
|
|
34
34
|
|
|
35
|
-
Python bindings for the
|
|
35
|
+
Modern `nogil` Python bindings for the Pcre2 library with `stdlib.re` api compatibility.
|
|
36
36
|
|
|
37
37
|
<p align="center">
|
|
38
38
|
<a href="https://github.com/ModelCloud/PyPcre/releases" style="text-decoration:none;"><img alt="GitHub release" src="https://img.shields.io/github/release/ModelCloud/Pcre.svg"></a>
|
|
@@ -43,7 +43,7 @@ Python bindings for the system PCRE2 library with a familiar `re`-style API.
|
|
|
43
43
|
</p>
|
|
44
44
|
|
|
45
45
|
## Latest News
|
|
46
|
-
* 10/
|
|
46
|
+
* 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.
|
|
47
47
|
* 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.
|
|
48
48
|
|
|
49
49
|
## Why PyPcre:
|
|
@@ -64,9 +64,29 @@ pip install PyPcre
|
|
|
64
64
|
|
|
65
65
|
The package prioritizes linking against the `libpcre2-8` shared library in system for fast install and max security protection which gets latest patches from OS. See [Building](#building) for manual build details.
|
|
66
66
|
|
|
67
|
+
## Platform Support (Validated):
|
|
68
|
+
|
|
69
|
+
`Linux`, `MacOS`, `Windows`, `WSL`, `FreeBSD`, `Solaris`
|
|
70
|
+
|
|
71
|
+
|
|
67
72
|
## Usage
|
|
68
73
|
|
|
69
|
-
|
|
74
|
+
|
|
75
|
+
If you already rely on the standard library `re`, migrating is as
|
|
76
|
+
simple as changing your import:
|
|
77
|
+
|
|
78
|
+
```python
|
|
79
|
+
import pcre as re
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
The module-level entry points (`match`, `search`, `fullmatch`, `findall`,
|
|
83
|
+
`finditer`, `split`, `sub`, `subn`, `compile`, `escape`, `purge`) expose the
|
|
84
|
+
same call signatures as their `re` counterparts, making existing code work
|
|
85
|
+
unchanged. Every standard flag with a PCRE2 equivalent—`IGNORECASE`,
|
|
86
|
+
`MULTILINE`, `DOTALL`, `VERBOSE`, `ASCII`, and friends—is supported via the
|
|
87
|
+
re-exported constants and the `pcre.Flag` enum.
|
|
88
|
+
|
|
89
|
+
### Sample Usage
|
|
70
90
|
|
|
71
91
|
```python
|
|
72
92
|
from pcre import match, search, findall, compile, Flag
|
|
@@ -78,15 +98,11 @@ pattern = compile(rb"\d+", flags=Flag.MULTILINE)
|
|
|
78
98
|
numbers = pattern.findall(b"line 1\nline 22")
|
|
79
99
|
```
|
|
80
100
|
|
|
81
|
-
`pcre` mirrors the core helpers from Python’s standard library `re` module
|
|
82
|
-
`match`, `search`, `fullmatch`, `finditer`, `findall`, and `compile
|
|
101
|
+
`pcre` mirrors the core helpers from Python’s standard library `re` module
|
|
102
|
+
`match`, `search`, `fullmatch`, `finditer`, `findall`, and `compile` while
|
|
83
103
|
exposing PCRE2’s extended flag set through the Pythonic `Flag` enum
|
|
84
104
|
(`Flag.CASELESS`, `Flag.MULTILINE`, `Flag.UTF`, ...).
|
|
85
105
|
|
|
86
|
-
### Platform Support:
|
|
87
|
-
|
|
88
|
-
Linux, MacOS, Windows, WSL, FreeBSD, Solaris
|
|
89
|
-
|
|
90
106
|
### Stdlib `re` compatibility
|
|
91
107
|
|
|
92
108
|
- Module-level helpers and the `Pattern` class follow the same call shapes as
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: PyPcre
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.3
|
|
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
|
|
@@ -32,7 +32,7 @@ Dynamic: license-file
|
|
|
32
32
|
|
|
33
33
|
# PyPcre (Python Pcre2 Binding)
|
|
34
34
|
|
|
35
|
-
Python bindings for the
|
|
35
|
+
Modern `nogil` Python bindings for the Pcre2 library with `stdlib.re` api compatibility.
|
|
36
36
|
|
|
37
37
|
<p align="center">
|
|
38
38
|
<a href="https://github.com/ModelCloud/PyPcre/releases" style="text-decoration:none;"><img alt="GitHub release" src="https://img.shields.io/github/release/ModelCloud/Pcre.svg"></a>
|
|
@@ -43,7 +43,7 @@ Python bindings for the system PCRE2 library with a familiar `re`-style API.
|
|
|
43
43
|
</p>
|
|
44
44
|
|
|
45
45
|
## Latest News
|
|
46
|
-
* 10/
|
|
46
|
+
* 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.
|
|
47
47
|
* 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.
|
|
48
48
|
|
|
49
49
|
## Why PyPcre:
|
|
@@ -64,9 +64,29 @@ pip install PyPcre
|
|
|
64
64
|
|
|
65
65
|
The package prioritizes linking against the `libpcre2-8` shared library in system for fast install and max security protection which gets latest patches from OS. See [Building](#building) for manual build details.
|
|
66
66
|
|
|
67
|
+
## Platform Support (Validated):
|
|
68
|
+
|
|
69
|
+
`Linux`, `MacOS`, `Windows`, `WSL`, `FreeBSD`, `Solaris`
|
|
70
|
+
|
|
71
|
+
|
|
67
72
|
## Usage
|
|
68
73
|
|
|
69
|
-
|
|
74
|
+
|
|
75
|
+
If you already rely on the standard library `re`, migrating is as
|
|
76
|
+
simple as changing your import:
|
|
77
|
+
|
|
78
|
+
```python
|
|
79
|
+
import pcre as re
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
The module-level entry points (`match`, `search`, `fullmatch`, `findall`,
|
|
83
|
+
`finditer`, `split`, `sub`, `subn`, `compile`, `escape`, `purge`) expose the
|
|
84
|
+
same call signatures as their `re` counterparts, making existing code work
|
|
85
|
+
unchanged. Every standard flag with a PCRE2 equivalent—`IGNORECASE`,
|
|
86
|
+
`MULTILINE`, `DOTALL`, `VERBOSE`, `ASCII`, and friends—is supported via the
|
|
87
|
+
re-exported constants and the `pcre.Flag` enum.
|
|
88
|
+
|
|
89
|
+
### Sample Usage
|
|
70
90
|
|
|
71
91
|
```python
|
|
72
92
|
from pcre import match, search, findall, compile, Flag
|
|
@@ -78,15 +98,11 @@ pattern = compile(rb"\d+", flags=Flag.MULTILINE)
|
|
|
78
98
|
numbers = pattern.findall(b"line 1\nline 22")
|
|
79
99
|
```
|
|
80
100
|
|
|
81
|
-
`pcre` mirrors the core helpers from Python’s standard library `re` module
|
|
82
|
-
`match`, `search`, `fullmatch`, `finditer`, `findall`, and `compile
|
|
101
|
+
`pcre` mirrors the core helpers from Python’s standard library `re` module
|
|
102
|
+
`match`, `search`, `fullmatch`, `finditer`, `findall`, and `compile` while
|
|
83
103
|
exposing PCRE2’s extended flag set through the Pythonic `Flag` enum
|
|
84
104
|
(`Flag.CASELESS`, `Flag.MULTILINE`, `Flag.UTF`, ...).
|
|
85
105
|
|
|
86
|
-
### Platform Support:
|
|
87
|
-
|
|
88
|
-
Linux, MacOS, Windows, WSL, FreeBSD, Solaris
|
|
89
|
-
|
|
90
106
|
### Stdlib `re` compatibility
|
|
91
107
|
|
|
92
108
|
- Module-level helpers and the `Pattern` class follow the same call shapes as
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
|
|
8
8
|
# PyPcre (Python Pcre2 Binding)
|
|
9
9
|
|
|
10
|
-
Python bindings for the
|
|
10
|
+
Modern `nogil` Python bindings for the Pcre2 library with `stdlib.re` api compatibility.
|
|
11
11
|
|
|
12
12
|
<p align="center">
|
|
13
13
|
<a href="https://github.com/ModelCloud/PyPcre/releases" style="text-decoration:none;"><img alt="GitHub release" src="https://img.shields.io/github/release/ModelCloud/Pcre.svg"></a>
|
|
@@ -18,7 +18,7 @@ Python bindings for the system PCRE2 library with a familiar `re`-style API.
|
|
|
18
18
|
</p>
|
|
19
19
|
|
|
20
20
|
## Latest News
|
|
21
|
-
* 10/
|
|
21
|
+
* 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.
|
|
22
22
|
* 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.
|
|
23
23
|
|
|
24
24
|
## Why PyPcre:
|
|
@@ -39,9 +39,29 @@ pip install PyPcre
|
|
|
39
39
|
|
|
40
40
|
The package prioritizes linking against the `libpcre2-8` shared library in system for fast install and max security protection which gets latest patches from OS. See [Building](#building) for manual build details.
|
|
41
41
|
|
|
42
|
+
## Platform Support (Validated):
|
|
43
|
+
|
|
44
|
+
`Linux`, `MacOS`, `Windows`, `WSL`, `FreeBSD`, `Solaris`
|
|
45
|
+
|
|
46
|
+
|
|
42
47
|
## Usage
|
|
43
48
|
|
|
44
|
-
|
|
49
|
+
|
|
50
|
+
If you already rely on the standard library `re`, migrating is as
|
|
51
|
+
simple as changing your import:
|
|
52
|
+
|
|
53
|
+
```python
|
|
54
|
+
import pcre as re
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
The module-level entry points (`match`, `search`, `fullmatch`, `findall`,
|
|
58
|
+
`finditer`, `split`, `sub`, `subn`, `compile`, `escape`, `purge`) expose the
|
|
59
|
+
same call signatures as their `re` counterparts, making existing code work
|
|
60
|
+
unchanged. Every standard flag with a PCRE2 equivalent—`IGNORECASE`,
|
|
61
|
+
`MULTILINE`, `DOTALL`, `VERBOSE`, `ASCII`, and friends—is supported via the
|
|
62
|
+
re-exported constants and the `pcre.Flag` enum.
|
|
63
|
+
|
|
64
|
+
### Sample Usage
|
|
45
65
|
|
|
46
66
|
```python
|
|
47
67
|
from pcre import match, search, findall, compile, Flag
|
|
@@ -53,15 +73,11 @@ pattern = compile(rb"\d+", flags=Flag.MULTILINE)
|
|
|
53
73
|
numbers = pattern.findall(b"line 1\nline 22")
|
|
54
74
|
```
|
|
55
75
|
|
|
56
|
-
`pcre` mirrors the core helpers from Python’s standard library `re` module
|
|
57
|
-
`match`, `search`, `fullmatch`, `finditer`, `findall`, and `compile
|
|
76
|
+
`pcre` mirrors the core helpers from Python’s standard library `re` module
|
|
77
|
+
`match`, `search`, `fullmatch`, `finditer`, `findall`, and `compile` while
|
|
58
78
|
exposing PCRE2’s extended flag set through the Pythonic `Flag` enum
|
|
59
79
|
(`Flag.CASELESS`, `Flag.MULTILINE`, `Flag.UTF`, ...).
|
|
60
80
|
|
|
61
|
-
### Platform Support:
|
|
62
|
-
|
|
63
|
-
Linux, MacOS, Windows, WSL, FreeBSD, Solaris
|
|
64
|
-
|
|
65
81
|
### Stdlib `re` compatibility
|
|
66
82
|
|
|
67
83
|
- Module-level helpers and the `Pattern` class follow the same call shapes as
|
|
@@ -32,7 +32,6 @@ from .pcre import (
|
|
|
32
32
|
finditer,
|
|
33
33
|
fullmatch,
|
|
34
34
|
match,
|
|
35
|
-
module_fullmatch,
|
|
36
35
|
parallel_map,
|
|
37
36
|
search,
|
|
38
37
|
split,
|
|
@@ -80,6 +79,28 @@ def escape(pattern: Any) -> Any:
|
|
|
80
79
|
return _std_re.escape(pattern)
|
|
81
80
|
|
|
82
81
|
|
|
82
|
+
# Compat: expose stdlib-style flag constants so migrating `re` users can
|
|
83
|
+
# continue referencing familiar names. Prefer `pcre.Flag` for new code.
|
|
84
|
+
_FLAG_ZERO = Flag(0)
|
|
85
|
+
_FLAG_COMPAT_ALIASES = {
|
|
86
|
+
"IGNORECASE": Flag.CASELESS,
|
|
87
|
+
"I": Flag.CASELESS,
|
|
88
|
+
"MULTILINE": Flag.MULTILINE,
|
|
89
|
+
"M": Flag.MULTILINE,
|
|
90
|
+
"DOTALL": Flag.DOTALL,
|
|
91
|
+
"S": Flag.DOTALL,
|
|
92
|
+
"VERBOSE": Flag.EXTENDED,
|
|
93
|
+
"X": Flag.EXTENDED,
|
|
94
|
+
"ASCII": Flag.NO_UTF | Flag.NO_UCP,
|
|
95
|
+
"A": Flag.NO_UTF | Flag.NO_UCP,
|
|
96
|
+
"UNICODE": _FLAG_ZERO,
|
|
97
|
+
"U": _FLAG_ZERO,
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
for _alias, _flag in _FLAG_COMPAT_ALIASES.items():
|
|
101
|
+
globals()[_alias] = _flag
|
|
102
|
+
|
|
103
|
+
|
|
83
104
|
__all__ = [
|
|
84
105
|
"Pattern",
|
|
85
106
|
"Match",
|
|
@@ -97,7 +118,6 @@ __all__ = [
|
|
|
97
118
|
"match",
|
|
98
119
|
"search",
|
|
99
120
|
"fullmatch",
|
|
100
|
-
"module_fullmatch",
|
|
101
121
|
"finditer",
|
|
102
122
|
"findall",
|
|
103
123
|
"parallel_map",
|
|
@@ -113,6 +133,8 @@ __all__ = [
|
|
|
113
133
|
"ERRORS_BY_MACRO",
|
|
114
134
|
]
|
|
115
135
|
|
|
136
|
+
__all__ += list(_FLAG_COMPAT_ALIASES.keys())
|
|
137
|
+
|
|
116
138
|
__all__ += list(_error_module.__all__)
|
|
117
139
|
__all__ += _EXPORTED_ERROR_CLASSES
|
|
118
140
|
|
|
@@ -556,12 +556,6 @@ def fullmatch(pattern: Any, string: Any, flags: FlagInput = 0) -> Match | None:
|
|
|
556
556
|
return compile(pattern, flags=flags).fullmatch(string)
|
|
557
557
|
|
|
558
558
|
|
|
559
|
-
def module_fullmatch(pattern: Any, string: Any, flags: FlagInput = 0) -> Match | None:
|
|
560
|
-
"""Compat helper for code expecting a distinct module-level fullmatch."""
|
|
561
|
-
|
|
562
|
-
return fullmatch(pattern, string, flags=flags)
|
|
563
|
-
|
|
564
|
-
|
|
565
559
|
def finditer(pattern: Any, string: Any, flags: FlagInput = 0) -> Iterable[Match]:
|
|
566
560
|
return compile(pattern, flags=flags).finditer(string)
|
|
567
561
|
|
|
@@ -9,7 +9,7 @@ build-backend = "setuptools.build_meta"
|
|
|
9
9
|
|
|
10
10
|
[project]
|
|
11
11
|
name = "PyPcre"
|
|
12
|
-
version = "0.2.
|
|
12
|
+
version = "0.2.3"
|
|
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"
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
# SPDX-License-Identifier: Apache-2.0
|
|
4
4
|
# Contact: qubitium@modelcloud.ai, x.com/qubitium
|
|
5
5
|
|
|
6
|
+
import inspect
|
|
6
7
|
import re
|
|
7
8
|
from enum import IntFlag
|
|
8
9
|
|
|
@@ -36,6 +37,22 @@ def test_error_aliases_and_escape():
|
|
|
36
37
|
assert pcre.escape(b"a+b") == re.escape(b"a+b")
|
|
37
38
|
|
|
38
39
|
|
|
40
|
+
def test_stdlib_style_flag_aliases():
|
|
41
|
+
assert pcre.IGNORECASE == pcre.Flag.CASELESS
|
|
42
|
+
assert pcre.I == pcre.Flag.CASELESS
|
|
43
|
+
assert pcre.MULTILINE == pcre.Flag.MULTILINE
|
|
44
|
+
assert pcre.M == pcre.Flag.MULTILINE
|
|
45
|
+
assert pcre.DOTALL == pcre.Flag.DOTALL
|
|
46
|
+
assert pcre.S == pcre.Flag.DOTALL
|
|
47
|
+
assert pcre.VERBOSE == pcre.Flag.EXTENDED
|
|
48
|
+
assert pcre.X == pcre.Flag.EXTENDED
|
|
49
|
+
ascii_alias = pcre.Flag.NO_UTF | pcre.Flag.NO_UCP
|
|
50
|
+
assert pcre.ASCII == ascii_alias
|
|
51
|
+
assert pcre.A == ascii_alias
|
|
52
|
+
assert pcre.UNICODE == 0
|
|
53
|
+
assert pcre.U == 0
|
|
54
|
+
|
|
55
|
+
|
|
39
56
|
def test_specific_compile_error_exposes_dedicated_exception():
|
|
40
57
|
with pytest.raises(pcre.PcreErrorMissingClosingParenthesis) as info:
|
|
41
58
|
pcre.compile("(")
|
|
@@ -236,3 +253,27 @@ def test_match_attributes_bytes():
|
|
|
236
253
|
assert match.lastgroup is None
|
|
237
254
|
assert match.regs == ((2, 4), (2, 3), (3, 4))
|
|
238
255
|
assert match.expand(br"[\1\2]") == b"[ab]"
|
|
256
|
+
|
|
257
|
+
|
|
258
|
+
def _signature_fingerprint(func):
|
|
259
|
+
signature = inspect.signature(func)
|
|
260
|
+
return tuple((param.name, param.kind, param.default) for param in signature.parameters.values())
|
|
261
|
+
|
|
262
|
+
|
|
263
|
+
def test_stdlib_function_signatures_align_with_pcre():
|
|
264
|
+
stdlib_functions = {
|
|
265
|
+
name: getattr(re, name)
|
|
266
|
+
for name in dir(re)
|
|
267
|
+
if not name.startswith("_") and inspect.isroutine(getattr(re, name))
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
for name, std_callable in stdlib_functions.items():
|
|
271
|
+
pcre_callable = getattr(pcre, name, None)
|
|
272
|
+
assert pcre_callable is not None, f"pcre is missing stdlib helper {name!r}"
|
|
273
|
+
assert inspect.isroutine(pcre_callable), f"pcre.{name} should be a function"
|
|
274
|
+
|
|
275
|
+
std_sig = _signature_fingerprint(std_callable)
|
|
276
|
+
pcre_sig = _signature_fingerprint(pcre_callable)
|
|
277
|
+
assert (
|
|
278
|
+
pcre_sig == std_sig
|
|
279
|
+
), f"Signature mismatch for {name!r}: pcre{pcre_sig!r} != re{std_sig!r}"
|
|
@@ -259,7 +259,6 @@ def _exercise_pattern(
|
|
|
259
259
|
"subn",
|
|
260
260
|
"module_match",
|
|
261
261
|
"module_search",
|
|
262
|
-
"module_fullmatch",
|
|
263
262
|
"module_findall",
|
|
264
263
|
"module_split",
|
|
265
264
|
"module_sub",
|
|
@@ -288,8 +287,6 @@ def _exercise_pattern(
|
|
|
288
287
|
pcre.match(pattern, subject, flags=flags)
|
|
289
288
|
elif op == "module_search":
|
|
290
289
|
pcre.search(pattern, subject, flags=flags)
|
|
291
|
-
elif op == "module_fullmatch":
|
|
292
|
-
pcre.fullmatch(pattern, subject, flags=flags)
|
|
293
290
|
elif op == "module_findall":
|
|
294
291
|
pcre.findall(pattern, subject, flags=flags)
|
|
295
292
|
elif op == "module_split":
|
|
@@ -27,10 +27,6 @@ def test_module_compile_and_match_shortcuts():
|
|
|
27
27
|
assert whole is not None
|
|
28
28
|
assert whole.span() == (0, 5)
|
|
29
29
|
|
|
30
|
-
module_whole = pcre.module_fullmatch(r"\d+", "12345")
|
|
31
|
-
assert module_whole is not None
|
|
32
|
-
assert module_whole.span() == (0, 5)
|
|
33
|
-
|
|
34
30
|
|
|
35
31
|
def test_module_finditer_and_findall_helpers():
|
|
36
32
|
matches = [m.group(0) for m in pcre.finditer(r"[A-Z]+", "abc DEF ghi JKL")]
|
|
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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|