Merge lp:~max-rabkin/ibid/debug-655643 into lp:~ibid-core/ibid/old-trunk-1.6

Proposed by Max Rabkin
Status: Merged
Approved by: Stefano Rivera
Approved revision: 978
Merged at revision: 979
Proposed branch: lp:~max-rabkin/ibid/debug-655643
Merge into: lp:~ibid-core/ibid/old-trunk-1.6
Diff against target: 42 lines (+19/-5)
1 file modified
ibid/plugins/debug.py (+19/-5)
To merge this branch: bzr merge lp:~max-rabkin/ibid/debug-655643
Reviewer Review Type Date Requested Status
Jonathan Hitchcock Approve
Stefano Rivera Approve
Review via email: mp+38408@code.launchpad.net

This proposal supersedes a proposal from 2010-10-06.

Commit message

Improve robustness of debug plugin, esp wrt non-message events.

Description of the change

Untested

To post a comment you must log in.
Revision history for this message
Stefano Rivera (stefanor) wrote : Posted in a previous version of this proposal

Should we not be doing something like

def extract_message(msg):
    if isinstance(msg, dict):
        return msg.get('raw', msg)
    return msg

Revision history for this message
Stefano Rivera (stefanor) wrote : Posted in a previous version of this proposal

LGTM

review: Approve
Revision history for this message
Stefano Rivera (stefanor) wrote : Posted in a previous version of this proposal

See bug, caught another one...

review: Needs Fixing
Revision history for this message
Stefano Rivera (stefanor) :
review: Approve
Revision history for this message
Jonathan Hitchcock (vhata) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'ibid/plugins/debug.py'
2--- ibid/plugins/debug.py 2010-06-28 20:21:20 +0000
3+++ ibid/plugins/debug.py 2010-10-14 11:41:09 +0000
4@@ -24,6 +24,19 @@
5 if 'exc_info' in event:
6 last_exc_event = event
7
8+def get_message(event):
9+ try:
10+ message = event.message
11+ except AttributeError:
12+ return None
13+
14+ try:
15+ message = message['raw']
16+ except (KeyError, TypeError):
17+ pass
18+
19+ return message
20+
21 class LastException(Processor):
22 features = (u'debug',)
23 usage = u"""last exception
24@@ -41,12 +54,13 @@
25 u"I'll make an exception for you.")))
26 else:
27 if kind.lower() == 'exception':
28- try:
29- lines = [u'%(type)s event "%(message)s" triggered ' %
30+ message = get_message(exc_event)
31+ if message is None:
32+ lines = [u'%s event triggered' % exc_event.type]
33+ else:
34+ lines = [u'%(type)s event %(message)r triggered ' %
35 {'type': exc_event.type,
36- 'message': exc_event.message['raw']}]
37- except KeyError:
38- lines = [u'%(type)s event triggered' % exc_event.type]
39+ 'message': message}]
40
41 lines += format_exception_only(*exc_event['exc_info'][:2])
42 elif 'event' in kind.lower():

Subscribers

People subscribed via source and target branches