Update colorama to 0.4.1
Fixes colorama unintentionally overriding multiple sys.stdout wrappers of our own.
And provides a fix for a SyntaxWarning on Python 3.8:
C:\Google\depot_tools\third_party\colorama\ansitowin32.py:43: SyntaxWarning: invalid escape sequence \[
ANSI_RE = re.compile('\033\[((?:\d|;)*)([a-zA-Z])')
Tests are updated to account for the annotation wrapper no longer being overriden.
A fix by agable for the annotation wrapper working with carriage returns is also included (https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/1592612).
Bug: 958138, 958321
Change-Id: I2fe1def85c66cfe5229a1c25c2f677e498593eea
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/1591513
Reviewed-by: Aaron Gable <agable@chromium.org>
Reviewed-by: Marc-Antoine Ruel <maruel@chromium.org>
Commit-Queue: Raul Tambre <raul@tambre.ee>
Auto-Submit: Raul Tambre <raul@tambre.ee>
diff --git a/gclient_utils.py b/gclient_utils.py
index 5b751b4..ead81c7 100644
--- a/gclient_utils.py
+++ b/gclient_utils.py
@@ -433,10 +433,20 @@
# Continue lockless.
obj[0] += out
- while '\n' in obj[0]:
- line, remaining = obj[0].split('\n', 1)
- if line:
- self._wrapped.write('%d>%s\n' % (index, line))
+ while True:
+ # TODO(agable): find both of these with a single pass.
+ cr_loc = obj[0].find('\r')
+ lf_loc = obj[0].find('\n')
+ if cr_loc == lf_loc == -1:
+ break
+ elif cr_loc == -1 or (lf_loc >= 0 and lf_loc < cr_loc):
+ line, remaining = obj[0].split('\n', 1)
+ if line:
+ self._wrapped.write('%d>%s\n' % (index, line))
+ elif lf_loc == -1 or (cr_loc >= 0 and cr_loc < lf_loc):
+ line, remaining = obj[0].split('\r', 1)
+ if line:
+ self._wrapped.write('%d>%s\r' % (index, line))
obj[0] = remaining
def flush(self):