1
1
mirror of https://github.com/mrabarnett/mrab-regex.git synced 2025-10-05 20:02:39 +02:00

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

This commit is contained in:
Matthew Barnett
2024-04-28 20:11:20 +01:00
parent 9c950f2c25
commit 2e3272be48
6 changed files with 16 additions and 9 deletions

View File

@@ -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:
@@ -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

View File

@@ -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

View File

@@ -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)
@@ -4067,11 +4067,11 @@ class Source:
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 = []

View File

@@ -241,7 +241,7 @@ __all__ = ["cache_all", "compile", "DEFAULT_VERSION", "escape", "findall",
"VERSION1", "X", "VERBOSE", "W", "WORD", "error", "Regex", "__version__",
"__doc__", "RegexFlag"]
__version__ = "2.5.141"
__version__ = "2.5.142"
# --------------------------------------------------------------------
# Public interface.

View File

@@ -4329,6 +4329,10 @@ thing
# 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)

View File

@@ -7,7 +7,7 @@ with open('README.rst', encoding='utf-8') as file:
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',
@@ -21,7 +21,6 @@ setup(
'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',
@@ -32,7 +31,7 @@ setup(
'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',