diff options
author | Guus Sliepen <guus@debian.org> | 2018-06-05 21:43:10 +0200 |
---|---|---|
committer | Guido Günther <agx@sigxcpu.org> | 2018-06-07 08:48:00 +0200 |
commit | 48ef0ecff04f52734a3e0424201df6f303d1c9cd (patch) | |
tree | de45bd38a9ac3fec9bfb51067a168181509b1f92 /gbp/deb | |
parent | 6c30ac945a6f17772100e3cf9cce8f2bd4dbad4e (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/deb')
-rw-r--r-- | gbp/deb/changelog.py | 8 |
1 files changed, 6 insertions, 2 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] |