Fix autoninja.py's regex string

Regex strings need to be raw or else double-escape all the \ characters,
but Python 2.7 doesn't reliably enforce this, so bugs have crept in.

The buggy regex from create_installer_archive.py that this was copied
from was deleted a while ago. However this bad pattern is pervasive in
Chrome and depot_tools, as crudely found by searching for:

  re\.[a-z]*\('.*\\[dsw\(\.]

An earlier instance of this was found when running some of our scripts
with Python 3.8.

Bug: 958138
Change-Id: If7ded5ae13f8cc36a5f6277c6ae0a2f54f88c3e4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/1590191
Reviewed-by: Dirk Pranke <dpranke@chromium.org>
Commit-Queue: Bruce Dawson <brucedawson@chromium.org>
changes/91/1590191/3
Bruce Dawson 6 years ago committed by Commit Bot
parent f61af56950
commit 56add621f0

@ -60,7 +60,7 @@ try:
with open(os.path.join(output_dir, 'args.gn')) as file_handle:
for line in file_handle:
# This regex pattern copied from create_installer_archive.py
m = re.match('^\s*use_goma\s*=\s*true(\s*$|\s*#.*$)', line)
m = re.match(r'^\s*use_goma\s*=\s*true(\s*$|\s*#.*$)', line)
if m:
use_goma = True
except IOError:

Loading…
Cancel
Save