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:
@@ -64,7 +64,7 @@ def compile(pattern, options=None):
|
||||
if options:
|
||||
raise error('pattern is already compiled, so '
|
||||
'options may not be specified')
|
||||
pattern = pattern._pattern
|
||||
return pattern
|
||||
options = options or Options()
|
||||
values = tuple(getattr(options, name) for name in Options.NAMES)
|
||||
return _Regexp._make(pattern, values)
|
||||
|
Reference in New Issue
Block a user