From 9875e180e5fd1b4096ca48f9386680f0bda6f709 Mon Sep 17 00:00:00 2001 From: John Budorick Date: Wed, 5 Dec 2018 22:57:31 +0000 Subject: [PATCH] subprocess2: cache the string-escape codec at load time. This is a speculative fix for subprocess being unable to find string-escape later in execution; the theory being that something (unclear what) is interfering w/ codecs' lookup logic and that calling lookup earlier would allow string-escape to be cached before any such interference. See crbug.com/912292#c2 for more. Bug: 912292 Change-Id: I0abdd394253c9a4984db7c6c81d044087edc68fd Reviewed-on: https://chromium-review.googlesource.com/c/1363753 Reviewed-by: Robbie Iannucci Commit-Queue: John Budorick --- subprocess2.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/subprocess2.py b/subprocess2.py index 26f626968..d899e4729 100644 --- a/subprocess2.py +++ b/subprocess2.py @@ -8,6 +8,7 @@ In theory you shouldn't need anything else in subprocess, or this module failed. """ import cStringIO +import codecs import errno import logging import os @@ -17,6 +18,9 @@ import sys import time import threading +# Cache the string-escape codec to ensure subprocess can find it later. +# See crbug.com/912292#c2 for context. +codecs.lookup('string-escape') # Constants forwarded from subprocess. PIPE = subprocess.PIPE