Commit 70eba7d2 authored by Raul Tambre's avatar Raul Tambre Committed by Commit Bot

setup_color: Don't fill created string buffer with nulls

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: 's avatarRobbie Iannucci <iannucci@chromium.org>
parent 71f0da3e
......@@ -67,7 +67,7 @@ def init():
_fields_ = [('Name', UNICODE_STRING),
('NameBuffer', ctypes.c_wchar_p)]
buf = ctypes.create_string_buffer('\0', 1024)
buf = ctypes.create_string_buffer(1024)
# Ask NT what the name of the object our stdout HANDLE is. It would be
# possible to use GetFileInformationByHandleEx, but it's only available
# on Vista+. If you're reading this in 2017 or later, feel free to
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment