Commit 48ef0ecf authored by Guus Sliepen's avatar Guus Sliepen Committed by Guido Günther

changelog: try iso8859-1 when utf-8 fails

Fall back to iso8859-1 when opening the changelog. Helps when importing
old versions.

Closes: #900841
Signed-off-by: Guido Günther's avatarGuido Günther <agx@sigxcpu.org>
parent 6c30ac94
......@@ -128,8 +128,12 @@ class ChangeLog(object):
self._cp = cp
def _read(self):
with open(self.filename, encoding='utf-8') as f:
self._contents = f.read()
try:
with open(self.filename, encoding='utf-8') as f:
self._contents = f.read()
except UnicodeDecodeError:
with open(self.filename, encoding='iso-8859-1') as f:
self._contents = f.read()
def __getitem__(self, item):
return self._cp[item]
......
......@@ -33,7 +33,10 @@ class GitVfs(object):
if binary:
self._data = io.BytesIO(content)
else:
self._data = io.StringIO(content.decode())
try:
self._data = io.StringIO(content.decode())
except UnicodeDecodeError:
self._data = io.StringIO(content.decode("iso-8859-1"))
def readline(self):
return self._data.readline()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment