grit: chrome_html: rewrite re.sub to avoid Python 3.7+ change
The Python folks decided to break re.sub behavior and have it randomly replace empty matches with non-empty strings. For example: >>> re.sub(r'(.*)', r'foo', 'asd') 'foofoo' To avoid this crazy pants behavior, we could make the regex match the entire string (by adding ^ and $ anchors), but this bit of code doesn't really need a regex at all. We're simply inserting the string "2x" before the last "/" in the filename. Rewrite the code to do a little ad-hoc string splitting instead as this is a bit easier to read. Bug: 983071 Test: `./grit/test_suite_all.py` passes Change-Id: I7aa005d685bb1019c464af1c1f12ce2701431ddb Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1755391Reviewed-by:Andrew Grieve <agrieve@chromium.org> Commit-Queue: Mike Frysinger <vapier@chromium.org> Cr-Commit-Position: refs/heads/master@{#687291}
Showing
Please register or sign in to comment