diff --git a/presubmit_canned_checks.py b/presubmit_canned_checks.py index 321858933..4b5227772 100644 --- a/presubmit_canned_checks.py +++ b/presubmit_canned_checks.py @@ -1645,6 +1645,8 @@ def CheckCIPDManifest(input_api, output_api, path=None, content=None): assert path is None, 'Cannot provide both "path" and "content".' cmd += ['-ensure-file=-'] kwargs['stdin'] = content + if input_api.sys.version_info.major != 2: + kwargs['stdin'] = kwargs['stdin'].encode('utf-8') # quick and dirty parser to extract checked packages. packages = [ l.split()[0] for l in (ll.strip() for ll in content.splitlines()) diff --git a/tests/presubmit_unittest.py b/tests/presubmit_unittest.py index e083c6cc9..00a65bab8 100755 --- a/tests/presubmit_unittest.py +++ b/tests/presubmit_unittest.py @@ -3125,7 +3125,7 @@ the current line as well! input_api, presubmit.OutputApi, content='manifest_content') self.assertEqual(command.cmd, ['cipd', 'ensure-file-verify', '-log-level', 'debug', '-ensure-file=-']) - self.assertEqual(command.stdin, 'manifest_content') + self.assertEqual(command.stdin, b'manifest_content') self.assertEqual(command.kwargs, { 'stdin': subprocess.PIPE, 'stdout': subprocess.PIPE, @@ -3151,7 +3151,7 @@ the current line as well! }) self.assertEqual(command.cmd, ['cipd', 'ensure-file-verify', '-ensure-file=-']) - self.assertEqual(command.stdin, content) + self.assertEqual(command.stdin, content.encode()) self.assertEqual(command.kwargs, { 'stdin': subprocess.PIPE, 'stdout': subprocess.PIPE,