[asterisk-commits] lib/python/asterisk/ari: Only attempt to init the parent of ... (testsuite[master])

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Mon Oct 5 07:53:09 CDT 2015


Anonymous Coward #1000019 has submitted this change and it was merged.

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(-)

Approvals:
  Anonymous Coward #1000019: Verified
  Joshua Colp: Looks good to me, approved



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: merged
Gerrit-Change-Id: I334d7c8dacb9ab5b3d7f3b918b6e43476d9c69c1
Gerrit-PatchSet: 1
Gerrit-Project: testsuite
Gerrit-Branch: master
Gerrit-Owner: Matt Jordan <mjordan at digium.com>
Gerrit-Reviewer: Anonymous Coward #1000019
Gerrit-Reviewer: Joshua Colp <jcolp at digium.com>



More information about the asterisk-commits mailing list