Merge lp:~didrocks/apport/handle-older-reports into lp:~apport-hackers/apport/trunk

Proposed by Didier Roche-Tolomelli
Status: Merged
Merged at revision: 3220
Proposed branch: lp:~didrocks/apport/handle-older-reports
Merge into: lp:~apport-hackers/apport/trunk
Diff against target: 18 lines (+7/-2)
1 file modified
apport/ui.py (+7/-2)
To merge this branch: bzr merge lp:~didrocks/apport/handle-older-reports
Reviewer Review Type Date Requested Status
Brian Murray Approve
Review via email: mp+354692@code.launchpad.net

Description of the change

Handle older reports without the remember key.

Old reports (generated pre-apport 2.20.10-0ubuntu4) may not have the remember key
and can be loaded afterwards (or after dist-upgrade), and thus, trigger a KeyError.
Consider it as false then.
Use try/expect for python2 support.
Fixes LP: #1791324

To post a comment you must log in.
Revision history for this message
Julian Andres Klode (juliank) wrote :

Would be cleaner with response.get('remember', False) IMO to avoid catching KeyErrors inside of self.remember_send_report()

Revision history for this message
Didier Roche-Tolomelli (didrocks) wrote :

Both are equivalent (it's not a hot code path), I'm opened to change it if that's preferred.

Revision history for this message
Julian Andres Klode (juliank) wrote :

Assuming it's a dict or has a get() method, of course.

Revision history for this message
Didier Roche-Tolomelli (didrocks) wrote :

It's a dict when returning from the on demand generated report.

It seems to be a dict when loaded from an old report as well:
"def load(self, file, binary=True, key_filter=None)"
-> If binary is False, binary data is not loaded; the dictionary key is
        created, but its value will be an empty string. If it is True, it is
        transparently uncompressed and available as dictionary byte array values.

Revision history for this message
Brian Murray (brian-murray) :
review: Approve
Revision history for this message
Didier Roche-Tolomelli (didrocks) wrote :

Brian, I can't merge that, do you mind doing it?

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'apport/ui.py'
2--- apport/ui.py 2018-06-25 16:23:29 +0000
3+++ apport/ui.py 2018-09-11 11:46:47 +0000
4@@ -305,8 +305,13 @@
5 self.restart()
6 if response['blacklist']:
7 self.report.mark_ignore()
8- if response['remember']:
9- self.remember_send_report(response['report'])
10+ try:
11+ if response['remember']:
12+ self.remember_send_report(response['report'])
13+ # use try/expect for python2 support. Old reports (generated pre-apport 2.20.10-0ubuntu4)
14+ # may not have the remember key and can be loaded afterwards (or after dist-upgrade)
15+ except KeyError:
16+ pass
17 if not response['report']:
18 return
19

Subscribers

People subscribed via source and target branches