Merge lp:~asac/gwibber/access_not_defined_msg_attr into lp:gwibber/1.2

Proposed by Alexander Sack
Status: Merged
Merged at revision: not available
Proposed branch: lp:~asac/gwibber/access_not_defined_msg_attr
Merge into: lp:gwibber/1.2
Diff against target: None lines
To merge this branch: bzr merge lp:~asac/gwibber/access_not_defined_msg_attr
Reviewer Review Type Date Requested Status
Dominic Evans (community) Approve
Review via email: mp+5534@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Alexander Sack (asac) wrote :

while reviewing indicate backport for jaunty, i found some oddity, that i think is logically wrong. Here what i said on irc:

21:30 < asac> its probably a theoretical issue, but wrong imo:
21:31 < asac> so first a message runs this:
21:31 < asac> if hasattr(message, "gId"):
21:31 < asac> message.is_duplicate = message.gId in seen
21:31 < asac> message.first_seen = False
21:31 < asac> then in the indicator code it runs:
21:31 < asac> if msg.first_seen and \
21:31 < asac> hasattr(msg, "is_unread") and msg.is_unread and \
21:31 < asac> hasattr(msg, "gId") and msg.gId not in self.indicator_items:
21:31 < asac> i think logcally it needs hasattr(msg.first_seen) and ...
21:31 < asac> or the first_seen needs to be moved after the "hasattr(msg, "gId")"
21:32 < asac> if you access msg.first_seen without it being defined it throws, right?
21:33 < asac> so given that first_seen only gets defined if hasattr(message, "gId"): the second msg.first_seen can throw (in theory)
21:34 < asac> would only happen if !hasattr(msg, "gId") ... i looked and that seems to be an unlikely event

296. By Alexander Sack

* gwibber/client.py: fix access to maybe not defined msg property
  in manage_indicator_items

Revision history for this message
Dominic Evans (oldmanuk) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'gwibber/client.py'
2--- gwibber/client.py 2009-04-13 16:58:40 +0000
3+++ gwibber/client.py 2009-04-14 19:44:02 +0000
4@@ -1026,7 +1026,7 @@
5 def manage_indicator_items(self, data, tab_num=None):
6 if not self.is_gwibber_active():
7 for msg in data:
8- if msg.first_seen and \
9+ if hasattr(msg, "first_seen") and msg.first_seen and \
10 hasattr(msg, "is_unread") and msg.is_unread and \
11 hasattr(msg, "gId") and msg.gId not in self.indicator_items:
12 indicator = indicate.IndicatorMessage()

Subscribers

People subscribed via source and target branches