From 23acfbd6427e8bde1f1e0e16fd459c253e215aaa Mon Sep 17 00:00:00 2001 From: Eric Blade Date: Tue, 15 Sep 2009 21:25:26 -0500 Subject: [PATCH] deal with KeyErrors in update() in a vaguely intelligent fashion --- pyfpdb/Hud.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/pyfpdb/Hud.py b/pyfpdb/Hud.py index 392aa216..77143d79 100644 --- a/pyfpdb/Hud.py +++ b/pyfpdb/Hud.py @@ -334,11 +334,16 @@ class Hud: self.update_table_position() for s in self.stat_dict: - statd = self.stat_dict[s] + try: + statd = self.stat_dict[s] + except KeyError: + print "KeyError at the start of the for loop in update in hud_main. How this can possibly happen is totally beyond my comprehension. Your HUD may be about to get really weird. -Eric" + print "(btw, the key was ", s, " and statd is...", statd + continue try: self.stat_windows[statd['seat']].player_id = statd['player_id'] #self.stat_windows[self.stat_dict[s]['seat']].player_id = self.stat_dict[s]['player_id'] - except: # omg, we have more seats than stat windows .. damn poker sites with incorrect max seating info .. let's force 10 here + except KeyError: # omg, we have more seats than stat windows .. damn poker sites with incorrect max seating info .. let's force 10 here self.max = 10 self.create(hand, config, self.stat_dict, self.cards) self.stat_windows[statd['seat']].player_id = statd['player_id']