From 43271f94de299679c4dd959d355cb833807adfda Mon Sep 17 00:00:00 2001 From: Raul Tambre Date: Tue, 16 Jul 2019 14:03:54 +0000 Subject: [PATCH] fetch: Decode gclient output if returning stdout In Python 3 the output of a subprocess is bytes, so they need to be decoded to be used as a string. This previously caused the following error if there was an existing checkout during a fetch: Traceback (most recent call last): File "C:\Google\depot_tools\\fetch.py", line 318, in sys.exit(main()) File "C:\Google\depot_tools\\fetch.py", line 313, in main return run(options, spec, root) File "C:\Google\depot_tools\\fetch.py", line 299, in run if not options.force and checkout.exists(): File "C:\Google\depot_tools\\fetch.py", line 98, in exists return (os.path.exists(os.path.join(gclient_root, b'.gclient')) or File "C:\Program Files\Python38\lib\ntpath.py", line 109, in join genericpath._check_arg_types('join', path, *paths) File "C:\Program Files\Python38\lib\genericpath.py", line 151, in _check_arg_types raise TypeError("Can't mix strings and bytes in path components") from None TypeError: Can't mix strings and bytes in path components Bug: 939847 Change-Id: Ibf5b4923268595ba439586d688894f92696ecbb7 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/1701403 Auto-Submit: Raul Tambre Reviewed-by: Dirk Pranke Commit-Queue: Raul Tambre --- fetch.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fetch.py b/fetch.py index 1a7464f721..56abfb9a6d 100755 --- a/fetch.py +++ b/fetch.py @@ -68,7 +68,7 @@ class Checkout(object): if self.options.dry_run: return '' if return_stdout: - return subprocess.check_output(cmd, **kwargs) + return subprocess.check_output(cmd, **kwargs).decode() else: try: subprocess.check_call(cmd, **kwargs)