Merge lp:~jibel/ubuntu/bionic/apport/lp1582950_2_ubiquity_hook into lp:~ubuntu-core-dev/ubuntu/bionic/apport/ubuntu

Proposed by Jean-Baptiste Lallement
Status: Merged
Approved by: Brian Murray
Approved revision: 2604
Merged at revision: 2606
Proposed branch: lp:~jibel/ubuntu/bionic/apport/lp1582950_2_ubiquity_hook
Merge into: lp:~ubuntu-core-dev/ubuntu/bionic/apport/ubuntu
Diff against target: 25 lines (+7/-1)
1 file modified
data/package-hooks/ (+7/-1)
To merge this branch: bzr merge lp:~jibel/ubuntu/bionic/apport/lp1582950_2_ubiquity_hook
Reviewer Review Type Date Requested Status
Brian Murray Needs Fixing
Ubuntu Core Development Team Pending
Review via email:

Description of the change Convert attachments to string when it is necessary.

To post a comment you must log in.
Revision history for this message
Brian Murray (brian-murray) wrote :

Thanks for working on this. I believe isinstance() is preferred to using type().

Did you test this with both scenarios outlined in the bug?

review: Needs Fixing
2604. By Jean-Baptiste Lallement Use isinstance() instead of type()

Revision history for this message
Jean-Baptiste Lallement (jibel) wrote :

Thanks for your review.

I changed the code to use isinstance()

I tested on bionic on a live session and an installed system as user and as root with sudo and the hook did not crash while it is crashing without the patch.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'data/package-hooks/'
2--- data/package-hooks/ 2017-09-27 17:55:28 +0000
3+++ data/package-hooks/ 2018-01-30 09:11:12 +0000
4@@ -26,6 +26,12 @@
5 elif os.path.exists(f):
6 apport.hookutils.attach_root_command_outputs(report, {ident: "cat '%s'" % f})
8+ if isinstance(report[ident], bytes):
9+ try:
10+ report[ident] = report[ident].decode('UTF-8', 'replace')
11+ except UnicodeDecodeError:
12+ pass
15 def prepare_duplicate_signature(syslog, collect_grub, collect_trace):
16 collect = ''
17@@ -57,7 +63,7 @@
19 def add_info(report, ui):
20 add_installation_log(report, 'UbiquitySyslog', 'syslog')
21- syslog = report['UbiquitySyslog'].decode('utf-8', 'ignore')
22+ syslog = report['UbiquitySyslog']
23 if 'Buffer I/O error on device' in syslog:
24 if'Attached .* CD-ROM (\w+)', syslog):
25 cd_drive ='Attached .* CD-ROM (\w+)', syslog).group(1)


People subscribed via source and target branches