[Reportbug-commits] [reportbug] 01/09: reportbug/utils.py: do not fail on decoding errors
Sandro Tosi
morph at moszumanska.debian.org
Sun Feb 12 17:13:05 UTC 2017
This is an automated email from the git hooks/post-receive script.
morph pushed a commit to branch master
in repository reportbug.
commit e3dbf8e335f9ea2a4c95276e8e0c88d5a65773e4
Author: Nis Martensen <nis.martensen at web.de>
Date: Thu Jan 26 00:09:43 2017 +0100
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':
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/reportbug/reportbug.git
More information about the Reportbug-commits
mailing list