Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 83b3aa8

Browse filesBrowse files
himself65targos
authored andcommitted
tools: remove deprecated python api
PR-URL: #49731 Fixes: #49729 Reviewed-By: Yagiz Nizipli <yagiz.nizipli@sentry.io> Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
1 parent 36e42aa commit 83b3aa8
Copy full SHA for 83b3aa8

File tree

Expand file treeCollapse file tree

1 file changed

+13
-4
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+13
-4
lines changed
Open diff view settings
Collapse file

‎tools/cpplint.py‎

Copy file name to clipboardExpand all lines: tools/cpplint.py
+13-4Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@
5454
import math # for log
5555
import os
5656
import re
57-
import sre_compile
5857
import string
5958
import sys
6059
import sysconfig
@@ -66,6 +65,16 @@
6665

6766
__VERSION__ = '1.6.1'
6867

68+
# sre_compile will be/has been removed in Python 3.13
69+
# use re._compiler instead
70+
# Refs: https://github.com/python/cpython/issues/105456
71+
# Refs: https://github.com/python/cpython/issues/91308
72+
try:
73+
srecompile = re._compiler.compile
74+
except AttributeError:
75+
import sre_compile
76+
srecompile = sre_compile.compile
77+
6978
try:
7079
# -- pylint: disable=used-before-assignment
7180
xrange # Python 2
@@ -1077,7 +1086,7 @@ def Match(pattern, s):
10771086
# performance reasons; factoring it out into a separate function turns out
10781087
# to be noticeably expensive.
10791088
if pattern not in _regexp_compile_cache:
1080-
_regexp_compile_cache[pattern] = sre_compile.compile(pattern)
1089+
_regexp_compile_cache[pattern] = srecompile(pattern)
10811090
return _regexp_compile_cache[pattern].match(s)
10821091

10831092

@@ -1095,14 +1104,14 @@ def ReplaceAll(pattern, rep, s):
10951104
string with replacements made (or original string if no replacements)
10961105
"""
10971106
if pattern not in _regexp_compile_cache:
1098-
_regexp_compile_cache[pattern] = sre_compile.compile(pattern)
1107+
_regexp_compile_cache[pattern] = srecompile(pattern)
10991108
return _regexp_compile_cache[pattern].sub(rep, s)
11001109

11011110

11021111
def Search(pattern, s):
11031112
"""Searches the string for the pattern, caching the compiled regexp."""
11041113
if pattern not in _regexp_compile_cache:
1105-
_regexp_compile_cache[pattern] = sre_compile.compile(pattern)
1114+
_regexp_compile_cache[pattern] = srecompile(pattern)
11061115
return _regexp_compile_cache[pattern].search(s)
11071116

11081117

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.