Skip to content

Commit

Permalink
Git issue 527: VERBOSE/X flag breaks \N escapes
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthew Barnett committed Apr 28, 2024
1 parent 9c950f2 commit 2e3272b
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 9 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:

env:
PYTHON_VER: '3.10' # Python to run test/cibuildwheel
CIBW_BUILD: cp37-* cp38-* cp39-* cp310-* cp311-* cp312-*
CIBW_BUILD: cp38-* cp39-* cp310-* cp311-* cp312-*
CIBW_TEST_COMMAND: python -m unittest regex.test_regex

jobs:
Expand Down Expand Up @@ -94,7 +94,7 @@ jobs:
# manylinux2014 >=19.3 3.7.8+, 3.8.4+, 3.9.0+ 2.17 (2012-12-25)
# manylinux_x_y >=20.3 3.8.10+, 3.9.5+, 3.10.0+ x.y
# manylinux2010 images EOL on 2022-08-01, it doesn't support cp311.
CIBW_BUILD: cp37-* cp38-* cp39-* cp310-*
CIBW_BUILD: cp38-* cp39-* cp310-*
CIBW_MANYLINUX_X86_64_IMAGE: manylinux2010
CIBW_ARCHS_LINUX: x86_64

Expand Down
4 changes: 4 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
Version: 2024.4.28

Git issue 527: `VERBOSE`/`X` flag breaks `\N` escapes

Version: 2024.4.16

Git issue 525: segfault when fuzzy matching empty list
Expand Down
6 changes: 3 additions & 3 deletions regex_3/_regex_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -1359,7 +1359,7 @@ def parse_named_char(source, info, in_set):
"Parses a named character."
saved_pos = source.pos
if source.match("{"):
name = source.get_while(NAMED_CHAR_PART)
name = source.get_while(NAMED_CHAR_PART, keep_spaces=True)
if source.match("}"):
try:
value = unicodedata.lookup(name)
Expand Down Expand Up @@ -4067,11 +4067,11 @@ def get_many(self, count=1):
self.pos = len(string)
return "".join(substring)

def get_while(self, test_set, include=True):
def get_while(self, test_set, include=True, keep_spaces=False):
string = self.string
pos = self.pos

if self.ignore_space:
if self.ignore_space and not keep_spaces:
try:
substring = []

Expand Down
2 changes: 1 addition & 1 deletion regex_3/regex.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@
"VERSION1", "X", "VERBOSE", "W", "WORD", "error", "Regex", "__version__",
"__doc__", "RegexFlag"]

__version__ = "2.5.141"
__version__ = "2.5.142"

# --------------------------------------------------------------------
# Public interface.
Expand Down
4 changes: 4 additions & 0 deletions regex_3/test_regex.py
Original file line number Diff line number Diff line change
Expand Up @@ -4329,6 +4329,10 @@ def test_hg_bugs(self):
# Git issue 525: segfault when fuzzy matching empty list
self.assertEqual(regex.match(r"(\L<foo>){e<=5}", "blah", foo=[]).span(), (0, 0))

# Git issue 527: `VERBOSE`/`X` flag breaks `\N` escapes
self.assertEqual(regex.compile(r'\N{LATIN SMALL LETTER A}').match('a').span(), (0, 1))
self.assertEqual(regex.compile(r'\N{LATIN SMALL LETTER A}', flags=regex.X).match('a').span(), (0, 1))

def test_fuzzy_ext(self):
self.assertEqual(bool(regex.fullmatch(r'(?r)(?:a){e<=1:[a-z]}', 'e')),
True)
Expand Down
5 changes: 2 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

setup(
name='regex',
version='2024.4.16',
version='2024.4.28',
description='Alternative regular expression module, to replace re.',
long_description=long_description,
long_description_content_type='text/x-rst',
Expand All @@ -21,7 +21,6 @@
'Intended Audience :: Developers',
'License :: OSI Approved :: Apache Software License',
'Operating System :: OS Independent',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
Expand All @@ -32,7 +31,7 @@
'Topic :: Text Processing',
'Topic :: Text Processing :: General',
],
python_requires='>=3.7',
python_requires='>=3.8',

package_dir={'regex': 'regex_3'},
py_modules=['regex.__init__', 'regex.regex', 'regex._regex_core',
Expand Down

0 comments on commit 2e3272b

Please sign in to comment.