From 2d55872fb1f735565fa0e34dbe7889dd31f09f00 Mon Sep 17 00:00:00 2001 From: Arend van Spriel Date: Thu, 5 Sep 2013 14:11:31 +0200 Subject: [PATCH] use Callback object constructing Socket Signed-off-by: Arend van Spriel Signed-off-by: Thomas Graf --- 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 f43fd2c..89773f6 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') -- 2.40.0