autoninja: fix strings with invalid escape sequences
Sincechanges/59/5859159/261fad561d6
(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 in61fad561d6
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] https://github.com/python/cpython/issues/98401 [3] https://github.com/python/cpython/pull/99011 Bug: b/364318216 Change-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>
parent
d43a3eb748
commit
22df6f8e62
Loading…
Reference in New Issue