Repository navigation
Path.rglob fails with *.* on Python 3.11.0a7 #91616
Copy link
Copy link
Closed
Labels
3.11only security fixesonly security fixesstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytopic-regextype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Description
Activity
- addedtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
on Apr 16, 2022 - addedstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directory3.11only security fixesonly security fixes
on Apr 16, 2022 Ah, I see.
>>> re.match(r'(?s:(?>.*?\.).*)\Z', 'a.txt') <re.Match object; span=(0, 5), match='a.txt'> >>> re.fullmatch(r'(?s:(?>.*?\.).*)\Z', 'a.txt')I thought that issues with
fullmatch()and atomic grouping were solved, but it is not so.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.
- added a commit that references this issue
on Apr 19, 2022
Metadata
Metadata
Assignees
Labels
3.11only security fixesonly security fixesstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytopic-regextype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
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