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

Proposed by Jean-Baptiste Lallement on 2018-01-23
Status: Merged
Approved by: Brian Murray on 2018-01-30
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/source_ubiquity.py (+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 2018-01-23 Needs Fixing on 2018-01-29
Ubuntu Core Development Team 2018-01-23 Pending
Review via email: mp+336474@code.launchpad.net

Description of the change

source_ubiquity.py: Convert attachments to string when it is necessary.

To post a comment you must log in.
Brian Murray (brian-murray) wrote :

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

https://docs.python.org/3/library/functions.html#type

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

review: Needs Fixing
2604. By Jean-Baptiste Lallement on 2018-01-30

source_ubiquity.py: Use isinstance() instead of type()

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/source_ubiquity.py'
2--- data/package-hooks/source_ubiquity.py 2017-09-27 17:55:28 +0000
3+++ data/package-hooks/source_ubiquity.py 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})
7
8+ if isinstance(report[ident], bytes):
9+ try:
10+ report[ident] = report[ident].decode('UTF-8', 'replace')
11+ except UnicodeDecodeError:
12+ pass
13+
14
15 def prepare_duplicate_signature(syslog, collect_grub, collect_trace):
16 collect = ''
17@@ -57,7 +63,7 @@
18
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 re.search('Attached .* CD-ROM (\w+)', syslog):
25 cd_drive = re.search('Attached .* CD-ROM (\w+)', syslog).group(1)

Subscribers

People subscribed via source and target branches