[Pyrex] Pyrex and None types
John (J5) Palmieri
johnp at redhat.com
Mon Apr 18 23:56:04 CEST 2005
I am having a problem with this code:
cdef class Message:
cdef DBusMessage *msg
def __init__(self, message_type=MESSAGE_TYPE_INVALID,
service=None, path=None, dbus_interface=None, method=None,
Message method_call=None,
name=None,
Message reply_to=None, error_name=None, error_message=None,
_create=1):
cdef char *cservice
cdef char *ciface
cdef DBusMessage *cmsg
ciface = NULL
if (dbus_interface != None):
ciface = interface
cservice = NULL
if service != None:
cservice = service
if not _create:
return
if message_type == MESSAGE_TYPE_METHOD_CALL:
self.msg = dbus_message_new_method_call(cservice, path, ciface, method)
elif message_type == MESSAGE_TYPE_METHOD_RETURN:
cmsg = method_call._get_msg()
self.msg = dbus_message_new_method_return(cmsg)
elif message_type == MESSAGE_TYPE_SIGNAL:
self.msg = dbus_message_new_signal(path, ciface, name)
elif message_type == MESSAGE_TYPE_ERROR:
cmsg = reply_to._get_msg()
self.msg = dbus_message_new_error(cmsg, error_name, error_message)
It compiles file but I get this error message at runtime:
Traceback (most recent call last):
File "test.py", line 6, in ?
obj.ListNames()
File "/home/boston/johnp/Devel/dbus/python/dbus.py", line 258, in
__call__
message = dbus_bindings.MethodCall(self._object_path,
self._interface, self._method_name)
File "dbus_bindings.pyx", line 1365, in
dbus_bindings.MethodCall.__init__
def has_sender(self, service):
File "dbus_bindings.pyx", line 1187, in dbus_bindings.Message.__init__
Message method_call,
TypeError: expected string or Unicode object, NoneType found
Any ideas how to fix this? It works fine if I set the dbus_interface to
some string. It only fails if it equals None. Thanks.
--
John (J5) Palmieri
Associate Software Engineer
Desktop Group
Red Hat, Inc.
Blog: http://martianrock.com
More information about the Pyrex
mailing list