Turns out GetConsoleMode fails if the user's console isn't native. This is sometimes the case for Git Bash.
Also moved the checking code out of the if block so it applies in generic console cases too.
This went unnoticed, because setup_color.py is currently only really used in Git scripts, which are piped.
Bug: 1001187
Change-Id: I93357e479f84122f759e419d15c02500809657d3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/1785605
Reviewed-by: Robbie Iannucci <iannucci@chromium.org>
Reviewed-by: Edward Lesmes <ehmaldonado@chromium.org>
Reviewed-by: Marc-Antoine Ruel <maruel@chromium.org>
Commit-Queue: Raul Tambre <raul@tambre.ee>
Auto-Submit: Raul Tambre <raul@tambre.ee>
Windows 10 has support for native ANSI control codes.
This means we don't have to wrap stdout/stderr with Colorama, which uses old CMD APIs to handle these sequences.
This change inadvertently also works around an issue on Python 3 where Colorama errors when bytes are output by gclient_utils.CheckCallAndFilter due to not wrapping sys.stdout.buffer.
Bug: 942522
Change-Id: Ic7dde620b01bd94eb50de353bfc0276cad045a45
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/1735566
Commit-Queue: Raul Tambre <raul@tambre.ee>
Reviewed-by: Marc-Antoine Ruel <maruel@chromium.org>
Auto-Submit: Raul Tambre <raul@tambre.ee>
This causes an error since Python 3.5 due to a regression (https://bugs.python.org/issue32745):
Traceback (most recent call last):
File "C:\Google\depot_tools\metrics.py", line 267, in print_notice_and_exit
yield
File "C:\Google\depot_tools\gclient.py", line 3153, in <module>
sys.exit(main(sys.argv[1:]))
File "C:\Google\depot_tools\gclient.py", line 3136, in main
setup_color.init()
File "C:\Google\depot_tools\setup_color.py", line 70, in init
buf = ctypes.create_string_buffer('\0', 1024)
File "C:\Program Files\Python38\lib\ctypes\__init__.py", line 63, in create_string_buffer
raise TypeError(init)
TypeError: <Unicode console <stderr>>.write: ArgumentError("argument 2: <class 'ValueError'>: embedded null character")
Simply not filling the buffer with NULLs doesn't change the behaviour.
Bug: 942522
Change-Id: I1feb81555e995597b0b70f4aee9151fea755510c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/1701402
Auto-Submit: Raul Tambre <raul@tambre.ee>
Commit-Queue: Robbie Iannucci <iannucci@chromium.org>
Reviewed-by: Robbie Iannucci <iannucci@chromium.org>
This enables gclient sync and gclient runhooks to run, barring hook script failures.
git cl upload also now works.
The scripts still work with Python 2.
There are no intended behaviour changes.
Bug: 942522
Change-Id: I2ac587b5f803ba7f5bb5e412337ce049f4b1a741
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/1524583
Commit-Queue: Raul Tambre <raul@tambre.ee>
Reviewed-by: Dirk Pranke <dpranke@chromium.org>