aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKonstantin Ryabitsev <konstantin@linuxfoundation.org>2021-07-12 10:44:06 -0400
committerKonstantin Ryabitsev <konstantin@linuxfoundation.org>2021-07-12 10:44:06 -0400
commit29a271ced77abb35f68a49fca24ea2dfce2844ae (patch)
treed054f9ef59a57bda0988751e6991de4999824938
parent80598acedd40608c001e788376aa8477b677e431 (diff)
downloadgrokmirror-29a271ced77abb35f68a49fca24ea2dfce2844ae.tar.gz
Handle incorrect unicode in description
The description file may contain incorrect unicode, so open it as bytes and drop errors when decoding. Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
-rw-r--r--grokmirror/__init__.py6
1 files changed, 3 insertions, 3 deletions
diff --git a/grokmirror/__init__.py b/grokmirror/__init__.py
index 073ba26..99772fe 100644
--- a/grokmirror/__init__.py
+++ b/grokmirror/__init__.py
@@ -232,11 +232,11 @@ def get_repo_defs(toplevel, gitdir, usenow=False, ignorerefs=None):
description = None
try:
descfile = os.path.join(fullpath, 'description')
- with open(descfile) as fh:
+ with open(descfile, 'rb') as fh:
contents = fh.read().strip()
- if len(contents) and contents.find('edit this file') < 0:
+ if len(contents) and contents.find(b'edit this file') < 0:
# We don't need to tell mirrors to edit this file
- description = contents
+ description = contents.decode(errors='replace')
except IOError:
pass