Tails Installer crashes when reporting errors whose message is not valid ASCII
Originally created by @intrigeri on #15166 (Redmine)
This got reported to me by a Debian user running Tails Installer 4.4.18 with French locales:
2017-08-12 14:08:26,435 [creator.py:747 (mount_device)] DEBUG: Mounting /org/freedesktop/UDisks2/block_devices/sdb1
2017-08-12 14:08:26,591 [creator.py:774 (mount_device)] DEBUG: Mounted /dev/sdb1 to /media/user/Tails
2017-08-12 14:08:28,594 [creator.py:440 (delete_liveos)] INFO: Suppression du système d'exploitation live existant
2017-08-12 14:08:28,598 [creator.py:444 (delete_liveos)] DEBUG: Considering /media/user/Tails/EFI
Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/tails_installer/gui.py", line 411, in on_start_clicked
self.begin()
File "/usr/lib/python2.7/dist-packages/tails_installer/gui.py", line 676, in begin
self.live.delete_liveos()
File "/usr/lib/python2.7/dist-packages/tails_installer/creator.py", line 467, in delete_liveos
% {'message': str(e)})
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 15: ordinal not in range(128)
It looks like we assume ASCII encoding for the exception string
representation, either in this string %-formatting operation or in
gui.py
where we catch TailsInstallerError
and display its message.
For the record, in Tails Install 4.4.18 the corresponding code is:
self.log.debug("Considering " + path)
if os.path.isfile(path):
[…]
elif os.path.isdir(path):
try:
_set_liberal_perms_recursive(path)
except OSError, e:
self.log.debug(_("Unable to chmod %(file)s: %(message)s")
% {'file': path, 'message': str(e)})
try:
shutil.rmtree(path)
except OSError, e:
raise TailsInstallerError(_("Unable to remove directory from"
" previous LiveOS: %(message)s")
% {'message': str(e)})
… and line 467 is the last one I’m quoting above.
I see we have lots of other instances of very similar pieces of code. In most cases, this bug will not break Tails Installer functionnality, because the affected code is about reporting a critical error that already happened. But it will prevent users from sending us useful bug reports (by preventing the actual error from being part of the bug report) and will create poor UX (by crashing instead of displaying an explanatory error message).
Feature Branch: kurono/bug/15166-installer-crashes-no-ascii