diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2025-01-02 12:11:21 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-01-02 12:11:21 (GMT) |
commit | a3711d1541c1b7987941b41d2247f87dae347117 (patch) | |
tree | d335b8acd65d95bfc8808f49823619d3c1b9d970 /Lib | |
parent | 8d16919a06a55a50756bf083221a6f6cab43de50 (diff) | |
download | cpython-a3711d1541c1b7987941b41d2247f87dae347117.zip cpython-a3711d1541c1b7987941b41d2247f87dae347117.tar.gz cpython-a3711d1541c1b7987941b41d2247f87dae347117.tar.bz2 |
gh-124130: Fix a bug in matching regular expression \B in empty string (GH-127007)
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/test/test_re.py | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/Lib/test/test_re.py b/Lib/test/test_re.py index 0d3599b..5538de6 100644 --- a/Lib/test/test_re.py +++ b/Lib/test/test_re.py @@ -978,18 +978,15 @@ class ReTests(unittest.TestCase): self.assertIsNone(re.fullmatch(br".+\B", b"abc", re.LOCALE)) self.assertIsNone(re.fullmatch(r".+\B", "ьюя")) self.assertTrue(re.fullmatch(r".+\B", "ьюя", re.ASCII)) - # However, an empty string contains no word boundaries, and also no - # non-boundaries. + # However, an empty string contains no word boundaries. self.assertIsNone(re.search(r"\b", "")) self.assertIsNone(re.search(r"\b", "", re.ASCII)) self.assertIsNone(re.search(br"\b", b"")) self.assertIsNone(re.search(br"\b", b"", re.LOCALE)) - # This one is questionable and different from the perlre behaviour, - # but describes current behavior. - self.assertIsNone(re.search(r"\B", "")) - self.assertIsNone(re.search(r"\B", "", re.ASCII)) - self.assertIsNone(re.search(br"\B", b"")) - self.assertIsNone(re.search(br"\B", b"", re.LOCALE)) + self.assertTrue(re.search(r"\B", "")) + self.assertTrue(re.search(r"\B", "", re.ASCII)) + self.assertTrue(re.search(br"\B", b"")) + self.assertTrue(re.search(br"\B", b"", re.LOCALE)) # A single word-character string has two boundaries, but no # non-boundary gaps. self.assertEqual(len(re.findall(r"\b", "a")), 2) |