Replacing None type by null list
authorRagner Magalhaes <ragner.magalhaes@openbossa.org>
Fri, 12 Dec 2008 14:11:32 +0000 (14:11 +0000)
committerAnderson Briglia <anderson.briglia@openbossa.org>
Sat, 28 Feb 2009 21:11:23 +0000 (17:11 -0400)
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 <agner.magalhaes@openbossa.org>
Acked-by: Ricardo Guimaraes <ricardo.guimaraes@openbossa.org>

git-svn-id: https://garage.maemo.org/svn/carman/branches/carman-0.7-beta2/python-purple@1701 596f6dd7-e928-0410-a184-9e12fd12cf7e

account.pyx

index 85d12d6..36902a7 100644 (file)
@@ -228,8 +228,8 @@ cdef class Account:
         cdef char *id = NULL
         cdef char *name = NULL
 
         cdef char *id = NULL
         cdef char *name = NULL
 
+        status_types = []
         if self.__exists:
         if self.__exists:
-            status_types = []
             iter = account.purple_account_get_status_types(self._get_structure())
             while iter:
                 c_statustype = <status.PurpleStatusType *> iter.data
             iter = account.purple_account_get_status_types(self._get_structure())
             while iter:
                 c_statustype = <status.PurpleStatusType *> iter.data
@@ -237,9 +237,8 @@ cdef class Account:
                 name = <char *> status.purple_status_type_get_name(c_statustype)
                 status_types.append((id, name))
                 iter = iter.next
                 name = <char *> 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)
 
 
     status_types = property(__get_status_types)
 
@@ -552,11 +551,11 @@ cdef class Account:
         cdef blist.PurpleBuddy *c_buddy = NULL
         cdef char *c_alias = NULL
 
         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)
 
         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 = <blist.PurpleBuddy *> iter.data
             while iter:
                 c_alias = NULL
                 c_buddy = <blist.PurpleBuddy *> iter.data
@@ -573,9 +572,8 @@ cdef class Account:
 
                     buddies_list.append(new_buddy)
                 iter = iter.next
 
                     buddies_list.append(new_buddy)
                 iter = iter.next
-            return buddies_list
-        else:
-            return None
+
+        return buddies_list
 
     def get_buddies(self):
         """
 
     def get_buddies(self):
         """
@@ -585,10 +583,10 @@ cdef class Account:
         cdef blist.PurpleBuddy *c_buddy = NULL
         cdef char *c_alias = NULL
 
         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)
 
         if self.__exists:
             iter = blist.purple_find_buddies(self._get_structure(), NULL)
 
-            buddies_list = []
             while iter:
                 c_alias = NULL
                 c_buddy = <blist.PurpleBuddy *> iter.data
             while iter:
                 c_alias = NULL
                 c_buddy = <blist.PurpleBuddy *> iter.data
@@ -602,9 +600,8 @@ cdef class Account:
 
                 buddies_list.append(new_buddy)
                 iter = iter.next
 
                 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:
 
     def request_add_buddy(self, buddy_username, buddy_alias):
         if buddy_alias: