summaryrefslogtreecommitdiff
path: root/gerrit_stream.py
diff options
context:
space:
mode:
authorDavid Pursehouse <david.pursehouse@sonyericsson.com>2011-10-27 17:23:53 +0900
committerDavid Pursehouse <david.pursehouse@sonymobile.com>2012-07-24 14:44:36 +0900
commit5dae4a1c98ab0bc4fe52fa0e0290c7384a871235 (patch)
treef187ab3c454992a362eae9e131cbefad444196ed /gerrit_stream.py
parent0e343379c4e3be9b4f041181602c63e7361c7764 (diff)
downloadpygerrit-5dae4a1c98ab0bc4fe52fa0e0290c7384a871235.tar.gz
Check for callable event handler on attach
When a listener is attached to the stream object, check that its "on_gerrit_event" is callable.
Diffstat (limited to 'gerrit_stream.py')
-rwxr-xr-xgerrit_stream.py4
1 files changed, 3 insertions, 1 deletions
diff --git a/gerrit_stream.py b/gerrit_stream.py
index 5578f7f..00c74ed 100755
--- a/gerrit_stream.py
+++ b/gerrit_stream.py
@@ -227,11 +227,13 @@ class GerritStream:
def attach(self, listener):
''' Attach the `listener` to the list of listeners.
Raise GerritStream error if the listener does not match the
- expected signature.
+ expected signature, or if its event handler is not callable.
'''
if not hasattr(listener, "on_gerrit_event"):
raise GerritStreamError("Listener must have `on_gerrit_event` " \
"event handler")
+ if not callable(listener.on_gerrit_event):
+ raise GerritStreamError("`on_gerrit_event` must be callable")
if not listener.on_gerrit_event.func_code.co_argcount == 2:
raise GerritStreamError("`on_gerrit_event` must take 1 arg")
if not listener in self.listeners: