tools: Use raw strings for regexps in python scripts (fixes #3677)

Starting with Python 3.12, use of invalid escape sequences in strings
is reported as a SyntaxWarning and will become a SyntaxError at a
later point.

Regular expressions use the backslash character a lot, which result in
warnings of this kind. Python docs recommend to generally use raw
strings for this purpose.
This commit is contained in:
Jacobo Aragunde Pérez
2024-04-12 15:53:51 +00:00
committed by Marshall Greenblatt
parent fb6b4df1ef
commit b15e34cfa1
3 changed files with 42 additions and 42 deletions

View File

@ -34,10 +34,10 @@ def MakeFileSegment(input, all_names):
# #define IDR_RESOURCE_NAME 12345
# [1] See https://crbug.com/684788#c18
regex = '#define\s([A-Za-z0-9_]{1,})\s+'
regex = r'#define\s([A-Za-z0-9_]{1,})\s+'
if contents.find('ui::WhitelistedResource') > 0:
regex += '.*<'
regex += '([0-9]{1,})'
regex += r'.*<'
regex += r'([0-9]{1,})'
# identify the defines in the file
p = re.compile(regex)