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>
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 @@
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