From: Ragner Magalhaes Date: Fri, 12 Dec 2008 14:11:32 +0000 (+0000) Subject: Replacing None type by null list X-Git-Url: http://git.maemo.org/git/?p=python-purple;a=commitdiff_plain;h=14e5eeb47b8ddc28b1d35fa74126e3cf18ace098 Replacing None type by null list Function that returns lists now returning null list instead None type to prevent "TypeError: 'NoneType' object is not interable" in "for loop" Signed-off-by: Ragner Magalhaes Acked-by: Ricardo Guimaraes git-svn-id: https://garage.maemo.org/svn/carman/branches/carman-0.7-beta2/python-purple@1701 596f6dd7-e928-0410-a184-9e12fd12cf7e --- diff --git a/account.pyx b/account.pyx index 85d12d6..36902a7 100644 --- a/account.pyx +++ b/account.pyx @@ -228,8 +228,8 @@ cdef class Account: cdef char *id = NULL cdef char *name = NULL + status_types = [] if self.__exists: - status_types = [] iter = account.purple_account_get_status_types(self._get_structure()) while iter: c_statustype = iter.data @@ -237,9 +237,8 @@ cdef class Account: name = status.purple_status_type_get_name(c_statustype) status_types.append((id, name)) iter = iter.next - return status_types - else: - return None + + return status_types status_types = property(__get_status_types) @@ -552,11 +551,11 @@ cdef class Account: cdef blist.PurpleBuddy *c_buddy = NULL cdef char *c_alias = NULL + buddies_list = [] if self.__exists and \ account.purple_account_is_connected(self._get_structure()): iter = blist.purple_find_buddies(self._get_structure(), NULL) - buddies_list = [] while iter: c_alias = NULL c_buddy = iter.data @@ -573,9 +572,8 @@ cdef class Account: buddies_list.append(new_buddy) iter = iter.next - return buddies_list - else: - return None + + return buddies_list def get_buddies(self): """ @@ -585,10 +583,10 @@ cdef class Account: cdef blist.PurpleBuddy *c_buddy = NULL cdef char *c_alias = NULL + buddies_list = [] if self.__exists: iter = blist.purple_find_buddies(self._get_structure(), NULL) - buddies_list = [] while iter: c_alias = NULL c_buddy = iter.data @@ -602,9 +600,8 @@ cdef class Account: buddies_list.append(new_buddy) iter = iter.next - return buddies_list - else: - return None + + return buddies_list def request_add_buddy(self, buddy_username, buddy_alias): if buddy_alias: