summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPierre Tardy <tardyp@gmail.com>2019-05-16 10:28:21 +0200
committerMike Frysinger <vapier@google.com>2019-07-11 01:33:37 +0000
commit2b7daff8cb0bb6a0836ca0cbc18f7f86b5eb0c86 (patch)
tree5a8e37a0b86696dff8abbe2f380f4b0b70f30892
parent242fcdd93b461263a1322093d432427736cf7e41 (diff)
downloadgit-repo-2b7daff8cb0bb6a0836ca0cbc18f7f86b5eb0c86.tar.gz
Don't try to decode when checking clone bundles
This fix exception with python3 with stack-trace: error: Cannot fetch platform_external_grpc-grpc-java.git (UnicodeDecodeError: 'utf-8' codec can't decode byte 0x96 in position 640: invalid start byte) [...] File "[...]project.py", line 2255, in _IsValidBundle if f.read(16) == '# v2 git bundle\n': File "/usr/lib/python3.5/codecs.py", line 321, in decode (result, consumed) = self._buffer_decode(data, self.errors, final) Even if we ask 16 characters, python buffered decoder will try to decode more in the buffer The patch works for python2 and python3, and open the file in byte mode so that decoding is not attemped Signed-off-by: Pierre Tardy <tardyp@gmail.com> Change-Id: I837ae3c5cd724b34670fc2a84e853431f482b20d Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/224642 Reviewed-by: Mike Frysinger <vapier@google.com> Reviewed-by: David Pursehouse <dpursehouse@collab.net> Tested-by: Mike Frysinger <vapier@google.com>
-rwxr-xr-xproject.py4
1 files changed, 2 insertions, 2 deletions
diff --git a/project.py b/project.py
index e0419e7a..67d3bb20 100755
--- a/project.py
+++ b/project.py
@@ -2261,8 +2261,8 @@ class Project(object):
2261 2261
2262 def _IsValidBundle(self, path, quiet): 2262 def _IsValidBundle(self, path, quiet):
2263 try: 2263 try:
2264 with open(path) as f: 2264 with open(path, 'rb') as f:
2265 if f.read(16) == '# v2 git bundle\n': 2265 if f.read(16) == b'# v2 git bundle\n':
2266 return True 2266 return True
2267 else: 2267 else:
2268 if not quiet: 2268 if not quiet: