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/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 Needs Fixing
Ubuntu Core Development Team 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.
Revision history for this message
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

source_ubiquity.py: 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
=== modified file 'data/package-hooks/source_ubiquity.py'
--- data/package-hooks/source_ubiquity.py 2017-09-27 17:55:28 +0000
+++ data/package-hooks/source_ubiquity.py 2018-01-30 09:11:12 +0000
@@ -26,6 +26,12 @@
26 elif os.path.exists(f):26 elif os.path.exists(f):
27 apport.hookutils.attach_root_command_outputs(report, {ident: "cat '%s'" % f})27 apport.hookutils.attach_root_command_outputs(report, {ident: "cat '%s'" % f})
2828
29 if isinstance(report[ident], bytes):
30 try:
31 report[ident] = report[ident].decode('UTF-8', 'replace')
32 except UnicodeDecodeError:
33 pass
34
2935
30def prepare_duplicate_signature(syslog, collect_grub, collect_trace):36def prepare_duplicate_signature(syslog, collect_grub, collect_trace):
31 collect = ''37 collect = ''
@@ -57,7 +63,7 @@
5763
58def add_info(report, ui):64def add_info(report, ui):
59 add_installation_log(report, 'UbiquitySyslog', 'syslog')65 add_installation_log(report, 'UbiquitySyslog', 'syslog')
60 syslog = report['UbiquitySyslog'].decode('utf-8', 'ignore')66 syslog = report['UbiquitySyslog']
61 if 'Buffer I/O error on device' in syslog:67 if 'Buffer I/O error on device' in syslog:
62 if re.search('Attached .* CD-ROM (\w+)', syslog):68 if re.search('Attached .* CD-ROM (\w+)', syslog):
63 cd_drive = re.search('Attached .* CD-ROM (\w+)', syslog).group(1)69 cd_drive = re.search('Attached .* CD-ROM (\w+)', syslog).group(1)

Subscribers

People subscribed via source and target branches