]> granicus.if.org Git - libnl/commitdiff
use Callback object constructing Socket
authorArend van Spriel <arend@broadcom.com>
Thu, 5 Sep 2013 12:11:31 +0000 (14:11 +0200)
committerThomas Graf <tgraf@suug.ch>
Thu, 5 Sep 2013 15:46:00 +0000 (17:46 +0200)
Signed-off-by: Arend van Spriel <arend@broadcom.com>
Signed-off-by: Thomas Graf <tgraf@suug.ch>
python/netlink/core.py

index f43fd2c1f0aaaa865061d083c169c1b3c2335a1b..89773f6f89fd59311d36d804601e27a03ec87035 100644 (file)
@@ -184,10 +184,12 @@ class Socket(object):
     """Netlink socket"""
 
     def __init__(self, cb=None):
-        if cb is None:
+        if isinstance(cb, Callback):
+            self._sock = capi.nl_socket_alloc_cb(cb._cb)
+        elif cb == None:
             self._sock = capi.nl_socket_alloc()
         else:
-            self._sock = capi.nl_socket_alloc_cb(cb)
+            raise Exception('\'cb\' parameter has wrong type')
 
         if self._sock is None:
             raise Exception('NULL pointer returned while allocating socket')