Can you please test if the attached patch fixes this bug?

(This bug already has multiple duplicates -- Bugs #848729, #849358,
#850687, #851865, #852129 all seem related.)
>From f1bbfcfd8ef09ae86f06ea1aa815e0a4c4e51e92 Mon Sep 17 00:00:00 2001
From: Nis Martensen <nis.marten...@web.de>
Date: Thu, 26 Jan 2017 00:09:43 +0100
Subject: [PATCH] reportbug/utils.py: do not fail on decoding errors

The dpkg status database and the reportbug configuration file might use
character sets different from the current locale. This can be
problematic when reading and decoding the file contents: The default
decoding error handler ("strict") errors out in such cases. Picking a
different one is more robust.
---
 reportbug/utils.py | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/reportbug/utils.py b/reportbug/utils.py
index 5c06afb..2de91ae 100644
--- a/reportbug/utils.py
+++ b/reportbug/utils.py
@@ -496,7 +496,7 @@ class AvailDB(object):
 
 def get_dpkg_database():
     try:
-        fp = open(STATUSDB)
+        fp = open(STATUSDB, errors="backslashreplace")
         if fp:
             return AvailDB(fp=fp)
     except IOError:
@@ -976,7 +976,7 @@ def parse_config_files():
     for filename in FILES:
         if os.path.exists(filename):
             try:
-                lex = our_lex(open(filename), posix=True)
+                lex = our_lex(open(filename, errors="backslashreplace"), posix=True)
             except IOError as msg:
                 continue
 
@@ -1235,7 +1235,7 @@ def exec_and_parse_bugscript(handler, bugscript):
     isattachments = False
     headers = pseudoheaders = text = ''
     attachments = []
-    fp = open(filename)
+    fp = open(filename, errors="backslashreplace")
     for line in fp.readlines():
         # we identify the blocks for headers and pseudo-h
         if line == '-- BEGIN HEADERS --\n':
-- 
2.1.4

Reply via email to