• Raul Tambre's avatar
    fix_encoding: Decode bytestrings on Python 3 · d9c1c856
    Raul Tambre authored
    Strings need to be passed to WriteConsoleW, otherwise an exception will be thrown:
    <Unicode console <stdout>>.write: ArgumentError("argument 2: <class 'TypeError'>: wrong type")
    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 3156, in <module>
        sys.exit(main(sys.argv[1:]))
      File "C:\Google\depot_tools\gclient.py", line 3142, in main
        return dispatcher.execute(OptionParser(), argv)
      File "C:\Google\depot_tools\subcommand.py", line 252, in execute
        return command(parser, args[1:])
      File "C:\Google\depot_tools\gclient.py", line 2699, in CMDsync
        ret = client.RunOnDeps('update', args)
      File "C:\Google\depot_tools\gclient.py", line 1771, in RunOnDeps
        self.RunHooksRecursively(self._options, pm)
      File "C:\Google\depot_tools\gclient.py", line 1064, in RunHooksRecursively
        hook.run()
      File "C:\Google\depot_tools\gclient.py", line 255, in run
        gclient_utils.CheckCallAndFilter(
      File "C:\Google\depot_tools\gclient_utils.py", line 592, in CheckCallAndFilter
        stdout_write(in_byte)
      File "C:\Google\depot_tools\gclient_utils.py", line 375, in write
        return self._wrapped.write(out)
      File "C:\Google\depot_tools\gclient_utils.py", line 343, in write
        self._wrapped.write(out, *args, **kwargs)
      File "C:\Google\depot_tools\fix_encoding.py", line 224, in write
        retval = self._WriteConsoleW(
    ctypes.ArgumentError: argument 2: <class 'TypeError'>: wrong type
    
    Bug: 984182
    Change-Id: Icffe0e0ea1fe2be5bc7607e32f58605d02f1f870
    Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/1778746
    Commit-Queue: Raul Tambre <raul@tambre.ee>
    Reviewed-by: 's avatarDirk Pranke <dpranke@chromium.org>
    Auto-Submit: Raul Tambre <raul@tambre.ee>
    d9c1c856
fix_encoding.py 11.9 KB