Petteri/telepaatti — Issue #8: Crash when user leaves room [KeyError]
Author: krf
Created: 2011-12-07 14:09:04+00:00
State: open

Crash when user leaves room without having been entered into the channel specific room list.

The attached patch is a work-around, as the invariant (user in room => JID in room list) seems to be flawed in the first place.

Backtrace:

```python
Exception in thread Thread-2:
Traceback (most recent call last):
File "/usr/lib/python2.7/threading.py", line 552, in __bootstrap_inner
self.run()
File "./3rdparty/telepaatti/telepaatti.py", line 60, in run
while self.client.Process(1) and self.connected:
File "/FOO/3rdparty/telepaatti/xmpp/dispatcher.py", line 303, in dispatch
handler['func'](session,stanza)
File "./3rdparty/telepaatti/telepaatti.py", line 1432, in presenceHandler
del (self.mucs[room][nick])
KeyError:
```

This patch avoids the crash:

```diff
From d8738eaf69dc1300b68ca444df950136b078f996 Mon Sep 17 00:00:00 2001
From: build
Date: Mon, 5 Dec 2011 14:42:17 +0100
Subject: [PATCH] Try to fix a crash in telepaatti (maybe related to our
custom jabber MUC setup)

---
3rdparty/telepaatti/telepaatti.py | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/3rdparty/telepaatti/telepaatti.py b/3rdparty/telepaatti/telepaatti.py
index 3a9ef78..a438978 100755
--- a/3rdparty/telepaatti/telepaatti.py
+++ b/3rdparty/telepaatti/telepaatti.py
@@ -1429,7 +1429,8 @@ class ClientThread(Thread):
nick, room))
elif inroom:
self.ircCommandPART(nick, room, 'left')
- del (self.mucs[room][nick])
+ if nick in self.mucs[room].keys():
+ del (self.mucs[room][nick])
else:
line = "%s is doing something" % nick
self.printDebug(line.encode('utf-8'))
--
1.7.5.4
```