[PATCH 7/8] use Callback object constructing Socket

Arend van Spriel arend at broadcom.com
Thu Sep 5 08:11:31 EDT 2013


Signed-off-by: Arend van Spriel <arend at broadcom.com>
---
 python/netlink/core.py |    6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/python/netlink/core.py b/python/netlink/core.py
index 104ba68..886ae2a 100644
--- a/python/netlink/core.py
+++ b/python/netlink/core.py
@@ -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')
-- 
1.7.10.4





More information about the libnl mailing list