Merge lp:~stefanor/ibid/none-response-377574 into lp:~ibid-core/ibid/old-trunk-pack-0.92

Proposed by Stefano Rivera
Status: Merged
Approved by: Jonathan Hitchcock
Approved revision: 645
Merged at revision: 655
Proposed branch: lp:~stefanor/ibid/none-response-377574
Merge into: lp:~ibid-core/ibid/old-trunk-pack-0.92
Diff against target: None lines
To merge this branch: bzr merge lp:~stefanor/ibid/none-response-377574
Reviewer Review Type Date Requested Status
Jonathan Hitchcock Approve
Michael Gorven Approve
Review via email: mp+6908@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Stefano Rivera (stefanor) wrote :

Debugging this one was a bitch because the bug stopped Dazzle from logging the statements that caused it.

In hindsight, it was obvious that the statement would have been "fml"

Revision history for this message
Michael Gorven (mgorven) wrote :

 review approve

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/event.py'
2--- ibid/event.py 2009-05-02 19:29:44 +0000
3+++ ibid/event.py 2009-05-30 18:26:08 +0000
4@@ -18,7 +18,10 @@
5 self[name] = value
6
7 def addresponse(self, response, params={}, processed=True):
8- if isinstance(response, basestring) and params:
9+ if response is None:
10+ # We want to detect this now, so we know which plugin is to blame
11+ raise Exception("Can't have a None response")
12+ elif isinstance(response, basestring) and params:
13 self.responses.append(response % params)
14 else:
15 self.responses.append(response)
16
17=== modified file 'ibid/plugins/lookup.py'
18--- ibid/plugins/lookup.py 2009-05-12 07:13:41 +0000
19+++ ibid/plugins/lookup.py 2009-05-30 18:29:42 +0000
20@@ -129,6 +129,9 @@
21 u"Sorry, it's broken, the FML admins must having a really bad day",
22 )
23
24+ class FMLException(Exception):
25+ pass
26+
27 def remote_get(self, id):
28 url = urljoin(self.api_url, 'view/%s?%s' % (
29 id.isalnum() and id + '/nocomment' or quote(id),
30@@ -137,7 +140,7 @@
31 dom = parse(urlopen(url))
32
33 if dom.getElementsByTagName('error'):
34- return
35+ raise FMLException(dom.getElementsByTagName('error')[0]childNodes[0].nodeValue)
36
37 items = dom.getElementsByTagName('item')
38 if items:
39@@ -162,6 +165,9 @@
40 def fml(self, event, id):
41 try:
42 quote = self.remote_get(id)
43+ except FMLException:
44+ event.addresponse(choice(self.failure_messages) % event.sender)
45+ return
46 except HTTPError:
47 event.addresponse(choice(self.failure_messages) % event.sender)
48 return
49@@ -175,9 +181,10 @@
50 def fml_default(self, event):
51 try:
52 event.addresponse(self.remote_get('random'))
53+ except FMLException:
54+ event.addresponse(choice(self.failure_messages) % event.sender)
55 except HTTPError:
56 event.addresponse(choice(self.failure_messages) % event.sender)
57- return
58
59 @match(r'^fml\s+categories$')
60 def list_categories(self, event):

Subscribers

People subscribed via source and target branches