Skip to content

Commit 930983a

Browse files
author
Matthew Barnett
committed
Git issue 546: Partial match not working in some instances with non-greedy capture
1 parent 64834c7 commit 930983a

File tree

5 files changed

+16
-20
lines changed

5 files changed

+16
-20
lines changed

changelog.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
Version: 2024.11.6
2+
3+
Git issue 546: Partial match not working in some instances with non-greedy capture
4+
15
Version: 2024.9.14
26

37
Reverted to actions/download-artifact@v3 and actions/upload-artifact@v3 in main.yml because GitHub Actions failed when using them.

regex_3/_regex.c

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -16535,9 +16535,6 @@ Py_LOCAL_INLINE(int) basic_match(RE_State* state, BOOL search) {
1653516535
RE_PARTIAL_RIGHT)
1653616536
return RE_ERROR_PARTIAL;
1653716537

16538-
if (pos >= limit)
16539-
break;
16540-
1654116538
/* Look for the tail string. */
1654216539
found = string_search(state, test, pos + 1, limit +
1654316540
length, TRUE, &is_partial);
@@ -16593,9 +16590,6 @@ Py_LOCAL_INLINE(int) basic_match(RE_State* state, BOOL search) {
1659316590
RE_PARTIAL_RIGHT)
1659416591
return RE_ERROR_PARTIAL;
1659516592

16596-
if (pos >= limit)
16597-
break;
16598-
1659916593
/* Look for the tail string. */
1660016594
found = string_search_fld(state, test, pos + 1, limit,
1660116595
&new_pos, &is_partial);
@@ -16651,9 +16645,6 @@ Py_LOCAL_INLINE(int) basic_match(RE_State* state, BOOL search) {
1665116645
if (pos <= state->text_start && state->partial_side == RE_PARTIAL_LEFT)
1665216646
return RE_ERROR_PARTIAL;
1665316647

16654-
if (pos <= limit)
16655-
break;
16656-
1665716648
/* Look for the tail string. */
1665816649
found = string_search_fld_rev(state, test, pos - 1,
1665916650
limit, &new_pos, &is_partial);
@@ -16713,9 +16704,6 @@ Py_LOCAL_INLINE(int) basic_match(RE_State* state, BOOL search) {
1671316704
RE_PARTIAL_RIGHT)
1671416705
return RE_ERROR_PARTIAL;
1671516706

16716-
if (pos >= limit)
16717-
break;
16718-
1671916707
/* Look for the tail string. */
1672016708
found = string_search_ign(state, test, pos + 1, limit +
1672116709
length, TRUE, &is_partial);
@@ -16773,9 +16761,6 @@ Py_LOCAL_INLINE(int) basic_match(RE_State* state, BOOL search) {
1677316761
if (pos <= state->text_start && state->partial_side == RE_PARTIAL_LEFT)
1677416762
return RE_ERROR_PARTIAL;
1677516763

16776-
if (pos <= limit)
16777-
break;
16778-
1677916764
/* Look for the tail string. */
1678016765
found = string_search_ign_rev(state, test, pos - 1,
1678116766
limit - length, TRUE, &is_partial);
@@ -16833,9 +16818,6 @@ Py_LOCAL_INLINE(int) basic_match(RE_State* state, BOOL search) {
1683316818
if (pos <= state->text_start && state->partial_side == RE_PARTIAL_LEFT)
1683416819
return RE_ERROR_PARTIAL;
1683516820

16836-
if (pos <= limit)
16837-
break;
16838-
1683916821
/* Look for the tail string. */
1684016822
found = string_search_rev(state, test, pos - 1, limit -
1684116823
length, TRUE, &is_partial);

regex_3/regex.py

Lines changed: 1 addition & 1 deletion
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.147"
244+
__version__ = "2.5.148"
245245

246246
# --------------------------------------------------------------------
247247
# Public interface.

regex_3/test_regex.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4346,6 +4346,16 @@ def test_hg_bugs(self):
43464346
self.assertEqual(regex.match(r"(?i)[^/]*b/xyz", "b/xy", partial=True).span(), (0, 4))
43474347
self.assertEqual(regex.match(r"(?i)[^/]*b/xyz", "b/yz", partial=True), None)
43484348

4349+
# Git issue 546: Partial match not working in some instances with non-greedy capture
4350+
self.assertEqual(bool(regex.match(r'<thinking>.*?</thinking>', '<', partial=True)), True)
4351+
self.assertEqual(bool(regex.match(r'<thinking>.*?</thinking>', '<thinking', partial=True)), True)
4352+
self.assertEqual(bool(regex.match(r'<thinking>.*?</thinking>', '<thinking>', partial=True)), True)
4353+
self.assertEqual(bool(regex.match(r'<thinking>.*?</thinking>', '<thinking>x', partial=True)), True)
4354+
self.assertEqual(bool(regex.match(r'<thinking>.*?</thinking>', '<thinking>xyz abc', partial=True)), True)
4355+
self.assertEqual(bool(regex.match(r'<thinking>.*?</thinking>', '<thinking>xyz abc foo', partial=True)), True)
4356+
self.assertEqual(bool(regex.match(r'<thinking>.*?</thinking>', '<thinking>xyz abc foo ', partial=True)), True)
4357+
self.assertEqual(bool(regex.match(r'<thinking>.*?</thinking>', '<thinking>xyz abc foo bar', partial=True)), True)
4358+
43494359
def test_fuzzy_ext(self):
43504360
self.assertEqual(bool(regex.fullmatch(r'(?r)(?:a){e<=1:[a-z]}', 'e')),
43514361
True)

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
setup(
1010
name='regex',
11-
version='2024.9.11',
11+
version='2024.11.6',
1212
description='Alternative regular expression module, to replace re.',
1313
long_description=long_description,
1414
long_description_content_type='text/x-rst',

0 commit comments

Comments
 (0)