-
-
Notifications
You must be signed in to change notification settings - Fork 30.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Path.rglob fails with *.* on Python 3.11.0a7 #91616
Comments
This comment was marked as outdated.
This comment was marked as outdated.
It's a bug of @serhiy-storchaka , the creator of PR #31982 (Add support of atomic grouping in re). Modules/_sre/sre_lib.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/Modules/_sre/sre_lib.h b/Modules/_sre/sre_lib.h
index 3472e65b87..c73e116143 100644
--- a/Modules/_sre/sre_lib.h
+++ b/Modules/_sre/sre_lib.h
@@ -1350,8 +1350,8 @@ SRE(match)(SRE_STATE* state, const SRE_CODE* pattern, int toplevel)
when the end of the group, represented by a SUCCESS op
code, is reached. */
/* Group Pattern begins at an offset of 1 code. */
- DO_JUMP(JUMP_ATOMIC_GROUP, jump_atomic_group,
- &pattern[1]);
+ DO_JUMP0(JUMP_ATOMIC_GROUP, jump_atomic_group,
+ &pattern[1]);
/* Test Exit Condition */
RETURN_ON_ERROR(ret); |
Ah, I see.
I thought that issues with Use the following tests in your PR: diff --git a/Lib/test/test_re.py b/Lib/test/test_re.py
index 959582e2f1..a5aa1b358d 100644
--- a/Lib/test/test_re.py
+++ b/Lib/test/test_re.py
@@ -2173,6 +2173,10 @@ def test_fullmatch_possessive_quantifiers(self):
self.assertIsNone(re.fullmatch(r'a*+', 'ab'))
self.assertIsNone(re.fullmatch(r'a?+', 'ab'))
self.assertIsNone(re.fullmatch(r'a{1,3}+', 'ab'))
+ self.assertTrue(re.fullmatch(r'a++b', 'ab'))
+ self.assertTrue(re.fullmatch(r'a*+b', 'ab'))
+ self.assertTrue(re.fullmatch(r'a?+b', 'ab'))
+ self.assertTrue(re.fullmatch(r'a{1,3}+b', 'ab'))
self.assertTrue(re.fullmatch(r'(?:ab)++', 'ab'))
self.assertTrue(re.fullmatch(r'(?:ab)*+', 'ab'))
@@ -2182,6 +2186,10 @@ def test_fullmatch_possessive_quantifiers(self):
self.assertIsNone(re.fullmatch(r'(?:ab)*+', 'abc'))
self.assertIsNone(re.fullmatch(r'(?:ab)?+', 'abc'))
self.assertIsNone(re.fullmatch(r'(?:ab){1,3}+', 'abc'))
+ self.assertTrue(re.fullmatch(r'(?:ab)++c', 'abc'))
+ self.assertTrue(re.fullmatch(r'(?:ab)*+c', 'abc'))
+ self.assertTrue(re.fullmatch(r'(?:ab)?+c', 'abc'))
+ self.assertTrue(re.fullmatch(r'(?:ab){1,3}+c', 'abc'))
def test_findall_possessive_quantifiers(self):
self.assertEqual(re.findall(r'a++', 'aab'), ['aa'])
@@ -2217,6 +2225,10 @@ def test_fullmatch_atomic_grouping(self):
self.assertIsNone(re.fullmatch(r'(?>a*)', 'ab'))
self.assertIsNone(re.fullmatch(r'(?>a?)', 'ab'))
self.assertIsNone(re.fullmatch(r'(?>a{1,3})', 'ab'))
+ self.assertTrue(re.fullmatch(r'(?>a+)b', 'ab'))
+ self.assertTrue(re.fullmatch(r'(?>a*)b', 'ab'))
+ self.assertTrue(re.fullmatch(r'(?>a?)b', 'ab'))
+ self.assertTrue(re.fullmatch(r'(?>a{1,3})b', 'ab'))
self.assertTrue(re.fullmatch(r'(?>(?:ab)+)', 'ab'))
self.assertTrue(re.fullmatch(r'(?>(?:ab)*)', 'ab'))
@@ -2226,6 +2238,10 @@ def test_fullmatch_atomic_grouping(self):
self.assertIsNone(re.fullmatch(r'(?>(?:ab)*)', 'abc'))
self.assertIsNone(re.fullmatch(r'(?>(?:ab)?)', 'abc'))
self.assertIsNone(re.fullmatch(r'(?>(?:ab){1,3})', 'abc'))
+ self.assertTrue(re.fullmatch(r'(?>(?:ab)+)c', 'abc'))
+ self.assertTrue(re.fullmatch(r'(?>(?:ab)*)c', 'abc'))
+ self.assertTrue(re.fullmatch(r'(?>(?:ab)?)c', 'abc'))
+ self.assertTrue(re.fullmatch(r'(?>(?:ab){1,3})c', 'abc'))
def test_findall_atomic_grouping(self):
self.assertEqual(re.findall(r'(?>a+)', 'aab'), ['aa']) |
Make the same change in POSSESSIVE_REPEAT. |
A draft: https://github.com/animalize/cpython/commit/8e00544280f054b663c056c6a99973749efe4b97 |
@serhiy-storchaka , please review #91681 . |
…ping or Possessive Quantifiers (GH-91681) These jumps should use DO_JUMP0() instead of DO_JUMP(): - JUMP_POSS_REPEAT_1 - JUMP_POSS_REPEAT_2 - JUMP_ATOMIC_GROUP
Bug report
On Python 3.11.0a7, calling
Path.rglob("*.*")
returns an iterator over no files, whereas on previous versions (including alpha 6) it would correctly return an iterator over all files in the directory and all of its children.The following code illustrates this problem:
Save this as
pathlib_rglob.py
.Output:
After much debugging I have tracked the issue to #32029
With that change,
fnmatch.translate("*.*")
gives(?s:(?>.*?\.).*)\Z
.With the change reverted (or on 3.11.0a6) its
(?s:(?=(?P<g0>.*?\.))(?P=g0).*)\Z
.I don't know what the difference between those amounts to, but the former doesn't work while the latter does:
Your environment
The text was updated successfully, but these errors were encountered: