From 2f6c7fd28a634dac7a71acf6ca7e91908a7d64be Mon Sep 17 00:00:00 2001 From: Josip Sokcevic Date: Thu, 7 Oct 2021 17:28:25 +0000 Subject: [PATCH] Cache the string-escape codec at bot_update start It looks the following speculative fix for string-escape codec worked for depot_tools subprocess2: https://crbug.com/912292#c2. Using the same approach for bot_update. R=gavinmak@google.com Bug: 1255228 Change-Id: I3244d34abad23f9fdbf648e24fc8a565df1474cb Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/3210521 Reviewed-by: Gavin Mak Commit-Queue: Josip Sokcevic --- recipes/recipe_modules/bot_update/resources/bot_update.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/recipes/recipe_modules/bot_update/resources/bot_update.py b/recipes/recipe_modules/bot_update/resources/bot_update.py index f38e48baa..08d92ed08 100755 --- a/recipes/recipe_modules/bot_update/resources/bot_update.py +++ b/recipes/recipe_modules/bot_update/resources/bot_update.py @@ -35,6 +35,12 @@ try: except ImportError: # pragma: no cover import urllib.parse as urlparse +# Cache the string-escape codec to ensure subprocess can find it later. +# See crbug.com/912292#c2 for context. +# TODO(crbug.com/1227140): Clean up when py2 is no longer supported. +if sys.version_info.major == 2: + codecs.lookup('string-escape') + # How many bytes at a time to read from pipes. BUF_SIZE = 256