From a0b0f12874bfd6033b577d20e18575aa4432377d Mon Sep 17 00:00:00 2001 From: Dan Harrington Date: Fri, 4 Jun 2021 17:57:10 +0000 Subject: [PATCH] Fix GetPylint with USE_PYTHON3=True kwargs['stdin'] is passed in to subprocess communicate(), which expects bytes, not str. Bug: 1215602 Change-Id: I95326eed08cffecd31abc6b0380de2a3c2ff3dd6 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2929386 Reviewed-by: Josip Sokcevic Commit-Queue: Dan H --- presubmit_canned_checks.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/presubmit_canned_checks.py b/presubmit_canned_checks.py index ed0b3af83..440d9948c 100644 --- a/presubmit_canned_checks.py +++ b/presubmit_canned_checks.py @@ -944,6 +944,7 @@ def GetPylint(input_api, input_api.logging.debug(' with extra PYTHONPATH: %r', extra_paths_list) def GetPylintCmd(flist, extra, parallel): + import sys # Windows needs help running python files so we explicitly specify # the interpreter to use. It also has limitations on the size of # the command-line, so we pass arguments via a pipe. @@ -975,6 +976,8 @@ def GetPylint(input_api, description += ' on %d cores' % input_api.cpu_count kwargs['stdin'] = '\n'.join(args + flist) + if sys.version_info.major != 2: + kwargs['stdin'] = kwargs['stdin'].encode('utf-8') return input_api.Command( name='Pylint (%s)' % description,