[Reportbug-maint] Bug#851322: reportbug: bug script fails with non-ascii characters in reportbugrc

Nis Martensen nis.martensen at web.de
Fri Jan 13 23:33:49 UTC 2017


Package: reportbug
Version: 7.1.2
Severity: normal

Dear Maintainer,

Configure a realname with non-ascii characters, then try to report a
bug on reportbug itself with reportbug 7.1.2.

If you have no locale set, reportbug fails immediately. (But I'm not
sure this case should be supported. You really should have appropriate
locale settings if have non-ascii characters in your name...)  With
proper locale settings, only the bug script still fails:

Traceback (most recent call last):
  File "/usr/share/bug/reportbug/script", line 25, in <module>
    for line in open(USERFILE, 'r'):
  File "/usr/lib/python3.5/encodings/ascii.py", line 26, in decode
    return codecs.ascii_decode(input, self.errors)[0]
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 369: ordinal not in range(128)

This is because the bug script is executed with LC_ALL=C, so it can
only deal with ascii characters by default.

There are several options to fix this, among them:
  (a) execute the bug script in the user's locale -- this will affect
bug scripts of all packages, so it may break other bug scripts and
lead to localized output of others,
  (b) modify the reportbug bug script to cope with non-ascii characters,
for example like this:

@@ -4,7 +4,7 @@
 import os
 import re
 
-OUT=os.fdopen(3, 'w')
+OUT=os.fdopen(3, 'w', encoding='utf-8', errors='backslashreplace')
 
 envprint = False
 for var in ['EDITOR', 'PAGER', 'VISUAL', 'REPORTBUGEMAIL', 'DEBEMAIL', 'EMAIL',
@@ -22,7 +22,7 @@ if os.path.exists(USERFILE):
     if envprint:
         print(file=OUT)
     print('** %s:' % USERFILE, file=OUT)
-    for line in open(USERFILE, 'r'):
+    for line in open(USERFILE, 'r', encoding='utf-8', errors='backslashreplace'):
         line = line.strip()
         if line and not line.startswith('#'):
             m = passwdre.match(line)



More information about the Reportbug-maint mailing list