8000 autoninja: fix strings with invalid escape sequences · kaidokert/depot_tools@22df6f8 · GitHub < 8000 link rel="alternate icon" class="js-site-favicon" type="image/png" href="https://github.githubassets.com/favicons/favicon.png">
[go: up one dir, main page]

Skip to content

Commit 22df6f8

Browse files
markmentovaiLUCI CQ
authored andcommitted
autoninja: fix strings with invalid escape sequences
Since 61fad56 (https://chromium-review.googlesource.com/c/5848450, 2024-09-11), autoninja under Python 3.12 presents these warnings: ``` …/autoninja.py:73: SyntaxWarning: invalid escape sequence '\s' m = re.match('instance\s*=\s*projects/([^/]*)/instances/.*', line) …/autoninja.py:92: SyntaxWarning: invalid escape sequence '\s' m = re.match('SISO_PROJECT=\s*(\S*)\s*', line) ``` This warning appears in Python 3.12 ([1], [2], [3]). '\s' and '\S' are not valid escape sequences in strings. r'\s' and r'\S' are valid in regular expressions, but outside of raw strings, they would need to be written as '\\s' and '\\S'. There is no reason to not use raw strings in this case, so the new regular expression pattern strings introduced in 61fad56 are changed to raw strings. [1] https://docs.python.org/3/whatsnew/3.12.html#:~:text=A%20backslash%2Dcharacter%20pair%20that%20is%20not%20a%20valid%20escape%20sequence%20now%20generates%20a%20SyntaxWarning%2C%20instead%20of%20DeprecationWarning. [2] python/cpython#98401 [3] python/cpython#99011 Bug: b/364318216 C 8000 hange-Id: I0f237976fe9c39208541ae78205f5bdbf126fa82 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5859159 Commit-Queue: Mark Mentovai <mark@chromium.org> Reviewed-by: Philipp Wollermann <philwo@google.com> Auto-Submit: Mark Mentovai <mark@chromium.org>
1 parent d43a3eb commit 22df6f8

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

autoninja.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ def _reclient_rbe_project():
6262
"""Returns RBE project used by reclient."""
6363
instance = os.environ.get('RBE_instance')
6464
if instance:
65-
m = re.match(instance, 'projects/([^/]*)/instances/.*')
65+
m = re.match(instance, r'projects/([^/]*)/instances/.*')
6666
if m:
6767
return m[1]
6868
reproxy_cfg_path = reclient_helper.find_reclient_cfg()

0 commit comments

Comments
 (0)
0