mirror of
https://github.com/google/re2.git
synced 2025-10-18 17:32:27 +08:00
python: fix re2.search(compiled, text)
The old code was accidentally recompiling the pattern and losing the options, both inefficient and incorrect. Thanks to @MajorTanya for the excellent diagnosis. This bug was introduced in CL 60290 and then copied over from the Abseil branch. Fixes #558. Change-Id: I072707003b444fb0934a310e14147b4d65b9da11 Reviewed-on: https://code-review.googlesource.com/c/re2/+/63830 Reviewed-by: Alan Donovan <adonovan@google.com>
This commit is contained in:
@@ -315,6 +315,12 @@ class Re2RegexpTest(ReRegexpTest):
|
||||
re2.purge()
|
||||
self.assertEqual(re2._Regexp._make.cache_info().currsize, 0)
|
||||
|
||||
def test_options(self):
|
||||
opt = re2.Options()
|
||||
opt.case_sensitive = False
|
||||
r = re2.compile('test', opt)
|
||||
self.assertIsNotNone(r.search('TEST'))
|
||||
self.assertIsNotNone(re2.search(r, 'TEST'))
|
||||
|
||||
class Re2EscapeTest(parameterized.TestCase):
|
||||
"""Contains tests that apply to the re2 module only.
|
||||
|
Reference in New Issue
Block a user