use Callback object constructing Socket

Signed-off-by: Arend van Spriel <arend@broadcom.com>
Signed-off-by: Thomas Graf <tgraf@suug.ch>
This commit is contained in:
Arend van Spriel 2013-09-05 14:11:31 +02:00 committed by Thomas Graf
parent 86207d47ab
commit 2d55872fb1

View 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')