aboutsummaryrefslogtreecommitdiffhomepage
path: root/gbp
diff options
context:
space:
mode:
authorGuus Sliepen <guus@debian.org>2018-06-05 21:43:10 +0200
committerGuido Günther <agx@sigxcpu.org>2018-06-07 08:48:00 +0200
commit48ef0ecff04f52734a3e0424201df6f303d1c9cd (patch)
treede45bd38a9ac3fec9bfb51067a168181509b1f92 /gbp
parent6c30ac945a6f17772100e3cf9cce8f2bd4dbad4e (diff)
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 <agx@sigxcpu.org>
Diffstat (limited to 'gbp')
-rw-r--r--gbp/deb/changelog.py8
-rw-r--r--gbp/git/vfs.py5
2 files changed, 10 insertions, 3 deletions
diff --git a/gbp/deb/changelog.py b/gbp/deb/changelog.py
index 5cfaaf79..dda9b753 100644
--- a/gbp/deb/changelog.py
+++ b/gbp/deb/changelog.py
@@ -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]
diff --git a/gbp/git/vfs.py b/gbp/git/vfs.py
index 8363f77b..ec47201a 100644
--- a/gbp/git/vfs.py
+++ b/gbp/git/vfs.py
@@ -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()