From 0ce8e05626365ffded83e54ef2d02d8f5f437547 Mon Sep 17 00:00:00 2001 From: Moshe Atlow Date: Wed, 8 Mar 2023 02:35:10 +0200 Subject: [PATCH] tools: replace sre_compile with re.compile --- tools/cpplint.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/tools/cpplint.py b/tools/cpplint.py index 06fc45abf1a0eb..c07f2a27c0483a 100755 --- a/tools/cpplint.py +++ b/tools/cpplint.py @@ -54,7 +54,6 @@ import math # for log import os import re -import sre_compile import string import sys import sysconfig @@ -1049,7 +1048,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) @@ -1067,14 +1066,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)