Skip to content

Commit 54fa96c

Browse files
committed
Re-organised files.
Updated to Unicode 17.0.0.
1 parent 4359a6a commit 54fa96c

File tree

15 files changed

+5864
-5647
lines changed

15 files changed

+5864
-5647
lines changed

MANIFEST.in

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,15 @@
1-
include regex_3/*.c
2-
include regex_3/*.h
3-
include regex_3/*.py
4-
include docs/*.*
5-
include tools/*.py
1+
exclude *.*
2+
include docs/Features.html
3+
include docs/UnicodeProperties.rst
64
include LICENSE.txt
75
include pyproject.toml
6+
include README.rst
7+
include regex/__init__.py
8+
include regex/_main.py
9+
include regex/_regex_core.py
10+
include regex/test_regex.py
11+
include src/_regex.c
12+
include src/_regex.h
13+
include src/_regex_unicode.c
14+
include src/_regex_unicode.h
15+
include tools/build_regex_unicode.py

README.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ The regex module releases the GIL during matching on instances of the built-in (
2121
Unicode
2222
-------
2323

24-
This module supports Unicode 16.0.0. Full Unicode case-folding is supported.
24+
This module supports Unicode 17.0.0. Full Unicode case-folding is supported.
2525

2626
Flags
2727
-----

docs/Features.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@ <h1>Multithreading</h1>
382382
</div>
383383
<div class="section" id="unicode">
384384
<h1>Unicode</h1>
385-
<p>This module supports Unicode 16.0.0. Full Unicode case-folding is supported.</p>
385+
<p>This module supports Unicode 17.0.0. Full Unicode case-folding is supported.</p>
386386
</div>
387387
<div class="section" id="flags">
388388
<h1>Flags</h1>

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,10 @@ requires-python = ">= 3.9"
3535
Homepage = "https://github.com/mrabarnett/mrab-regex"
3636

3737
[tool.setuptools]
38-
package-dir = {regex = "regex_3"}
38+
package-dir = {"regex" = "regex"}
3939
py-modules = [
4040
"regex.__init__",
41-
"regex.regex",
41+
"regex._main",
4242
"regex._regex_core",
4343
"regex.test_regex",
4444
]

regex/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import regex._main
2+
from regex._main import *
3+
__all__ = regex._main.__all__

regex_3/regex.py renamed to regex/_main.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@
241241
"VERSION1", "X", "VERBOSE", "W", "WORD", "error", "Regex", "__version__",
242242
"__doc__", "RegexFlag"]
243243

244-
__version__ = "2.5.162"
244+
__version__ = "2025.9.18"
245245

246246
# --------------------------------------------------------------------
247247
# Public interface.
@@ -414,8 +414,8 @@ def escape(pattern, special_only=True, literal_spaces=False):
414414
# --------------------------------------------------------------------
415415
# Internals.
416416

417-
import regex._regex_core as _regex_core
418-
import regex._regex as _regex
417+
from regex import _regex_core
418+
from regex import _regex
419419
from threading import RLock as _RLock
420420
from locale import getpreferredencoding as _getpreferredencoding
421421
from regex._regex_core import *
@@ -429,7 +429,7 @@ def escape(pattern, special_only=True, literal_spaces=False):
429429
# Version 0 is the old behaviour, compatible with the original 're' module.
430430
# Version 1 is the new behaviour, which differs slightly.
431431

432-
DEFAULT_VERSION = VERSION0
432+
DEFAULT_VERSION = RegexFlag.VERSION0
433433

434434
_METACHARS = frozenset("()[]{}?*+|^$\\.-#&~")
435435

regex_3/_regex_core.py renamed to regex/_regex_core.py

Lines changed: 40 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
import unicodedata
1919
from collections import defaultdict
2020

21-
import regex._regex as _regex
21+
from regex import _regex
2222

2323
__all__ = ["A", "ASCII", "B", "BESTMATCH", "D", "DEBUG", "E", "ENHANCEMATCH",
2424
"F", "FULLCASE", "I", "IGNORECASE", "L", "LOCALE", "M", "MULTILINE", "P",
@@ -121,7 +121,42 @@ def __repr__(self):
121121

122122
__str__ = object.__str__
123123

124-
globals().update(RegexFlag.__members__)
124+
# Put the flags into the module namespace. Being explicit here helps tools like
125+
# linters and IDEs understand the code better.
126+
ASCII = RegexFlag.ASCII
127+
BESTMATCH = RegexFlag.BESTMATCH
128+
DEBUG = RegexFlag.DEBUG
129+
DOTALL = RegexFlag.DOTALL
130+
ENHANCEMATCH = RegexFlag.ENHANCEMATCH
131+
FULLCASE = RegexFlag.FULLCASE
132+
IGNORECASE = RegexFlag.IGNORECASE
133+
LOCALE = RegexFlag.LOCALE
134+
MULTILINE = RegexFlag.MULTILINE
135+
POSIX = RegexFlag.POSIX
136+
REVERSE = RegexFlag.REVERSE
137+
TEMPLATE = RegexFlag.TEMPLATE
138+
UNICODE = RegexFlag.UNICODE
139+
VERBOSE = RegexFlag.VERBOSE
140+
VERSION0 = RegexFlag.VERSION0
141+
VERSION1 = RegexFlag.VERSION1
142+
WORD = RegexFlag.WORD
143+
A = RegexFlag.A
144+
B = RegexFlag.B
145+
D = RegexFlag.D
146+
E = RegexFlag.E
147+
F = RegexFlag.F
148+
I = RegexFlag.I
149+
L = RegexFlag.L
150+
M = RegexFlag.M
151+
P = RegexFlag.P
152+
R = RegexFlag.R
153+
S = RegexFlag.S
154+
U = RegexFlag.U
155+
V0 = RegexFlag.V0
156+
V1 = RegexFlag.V1
157+
W = RegexFlag.W
158+
X = RegexFlag.X
159+
T = RegexFlag.T
125160

126161
DEFAULT_VERSION = VERSION1
127162

@@ -2488,7 +2523,7 @@ def fix_groups(self, pattern, reverse, fuzzy):
24882523
self._key = self.__class__, self.group
24892524

24902525
def remove_captures(self):
2491-
raise error("group reference not allowed", pattern, self.position)
2526+
raise error("group reference not allowed", self.pattern, self.position)
24922527

24932528
def _compile(self, reverse, fuzzy):
24942529
return [(OP.GROUP_CALL, self.call_ref)]
@@ -3058,7 +3093,7 @@ def _compile(self, reverse, fuzzy):
30583093
def dump(self, indent, reverse):
30593094
group = self.group
30603095
if group < 0:
3061-
group = private_groups[group]
3096+
group = self.info.private_groups[group]
30623097
print("{}GROUP {}".format(INDENT * indent, group))
30633098
self.subpattern.dump(indent + 1, reverse)
30643099

@@ -3413,7 +3448,7 @@ def fix_groups(self, pattern, reverse, fuzzy):
34133448
self._key = self.__class__, self.group, self.case_flags
34143449

34153450
def remove_captures(self):
3416-
raise error("group reference not allowed", pattern, self.position)
3451+
raise error("group reference not allowed", self.pattern, self.position)
34173452

34183453
def _compile(self, reverse, fuzzy):
34193454
flags = 0

regex_3/test_regex.py renamed to regex/test_regex.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -883,7 +883,7 @@ def test_bug_817234(self):
883883
def test_empty_array(self):
884884
# SF buf 1647541.
885885
import array
886-
for typecode in 'bBuhHiIlLfd':
886+
for typecode in 'bBhHiIlLfd':
887887
a = array.array(typecode)
888888
self.assertEqual(regex.compile(b"bla").match(a), None)
889889
self.assertEqual(regex.compile(b"").match(a)[1 : ], ())

regex_3/__init__.py

Lines changed: 0 additions & 3 deletions
This file was deleted.

setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
macros.append(("Py_GIL_DISABLED", "1"))
1212

1313
setup(
14-
ext_modules=[Extension('regex._regex', [join('regex_3', '_regex.c'),
15-
join('regex_3', '_regex_unicode.c')])],
14+
ext_modules=[Extension('regex._regex', ['src/_regex.c',
15+
'src/_regex_unicode.c'])],
1616
define_macros=macros,
1717
)

0 commit comments

Comments
 (0)