Remove deprecated sre_compile from cpplint

This uses `re` instead, which should have similar performance with python3.

Bug: 1517826
Change-Id: If03f386d26590dcae7da6b4f27ec1ea4926065fa
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5197707
Reviewed-by: Scott Lee <ddoman@chromium.org>
Commit-Queue: Michael Achenbach <machenbach@chromium.org>
Reviewed-by: Brian Ryner <bryner@google.com>
changes/07/5197707/2
Michael Achenbach 2 years ago committed by LUCI CQ
parent f5dd9dda9e
commit a5aaf5bc34

11
cpplint.py vendored

@ -52,11 +52,6 @@ import string
import sys
import unicodedata
# FIXME(https://crbug.com/1517826): Replace deprecated import of sre_compile.
import warnings
with warnings.catch_warnings():
warnings.filterwarnings("ignore", category=DeprecationWarning)
import sre_compile
_USAGE = r"""
Syntax: cpplint.py [--verbose=#] [--output=vs7] [--filter=-x,+y,...]
@ -860,7 +855,7 @@ def Match(pattern, s):
# performance reasons; factoring it out into a separate function turns out
# to be noticeably expensive.
if pattern not in _regexp_compile_cache:
_regexp_compile_cache[pattern] = sre_compile.compile(pattern)
_regexp_compile_cache[pattern] = re.compile(pattern)
return _regexp_compile_cache[pattern].match(s)
@ -878,14 +873,14 @@ def ReplaceAll(pattern, rep, s):
string with replacements made (or original string if no replacements)
"""
if pattern not in _regexp_compile_cache:
_regexp_compile_cache[pattern] = sre_compile.compile(pattern)
_regexp_compile_cache[pattern] = re.compile(pattern)
return _regexp_compile_cache[pattern].sub(rep, s)
def Search(pattern, s):
"""Searches the string for the pattern, caching the compiled regexp."""
if pattern not in _regexp_compile_cache:
_regexp_compile_cache[pattern] = sre_compile.compile(pattern)
_regexp_compile_cache[pattern] = re.compile(pattern)
return _regexp_compile_cache[pattern].search(s)

Loading…
Cancel
Save