[Asterisk-code-review] lib/python/asterisk/ari: Only attempt to init the parent of ... (testsuite[master])
Matt Jordan
asteriskteam at digium.com
Mon Oct 5 07:52:01 CDT 2015
Matt Jordan has uploaded a new change for review.
https://gerrit.asterisk.org/1374
Change subject: lib/python/asterisk/ari: Only attempt to init the parent of AriClientProtocol
......................................................................
lib/python/asterisk/ari: Only attempt to init the parent of AriClientProtocol
Newer versions of Autobahn require the derived classes of
WebSocketClientProtocol to initialize the base classes. However, older versions
of Autobahn use old style Python classes without an initializer. As a result,
the only way to handle this situation is to attempt to initialize the parent
class(es), and catch the error. Since initializing an old style class with a
call to super will always raise a TypeError, we opt for that approach here.
Change-Id: I334d7c8dacb9ab5b3d7f3b918b6e43476d9c69c1
---
M lib/python/asterisk/ari.py
1 file changed, 7 insertions(+), 1 deletion(-)
git pull ssh://gerrit.asterisk.org:29418/testsuite refs/changes/74/1374/1
diff --git a/lib/python/asterisk/ari.py b/lib/python/asterisk/ari.py
index 740c986..1649f49 100644
--- a/lib/python/asterisk/ari.py
+++ b/lib/python/asterisk/ari.py
@@ -376,7 +376,13 @@
:param receiver The event receiver
"""
- WebSocketClientProtocol.__init__(self)
+ try:
+ super(AriClientProtocol, self).__init__()
+ except TypeError as te:
+ # Older versions of Autobahn use old style classes with no initializer.
+ # Newer versions must have their initializer called by derived
+ # implementations.
+ LOGGER.debug("AriClientProtocol: TypeError thrown in init: {0}".format(te))
LOGGER.debug("Made me a client protocol!")
self.receiver = receiver
self.factory = factory
--
To view, visit https://gerrit.asterisk.org/1374
To unsubscribe, visit https://gerrit.asterisk.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I334d7c8dacb9ab5b3d7f3b918b6e43476d9c69c1
Gerrit-PatchSet: 1
Gerrit-Project: testsuite
Gerrit-Branch: master
Gerrit-Owner: Matt Jordan <mjordan at digium.com>
More information about the asterisk-code-review
mailing list