[Zodb-checkins] CVS: ZODB/src/persistent/pickle - pickle.c:1.2.10.1

Jeremy Hylton jeremy at zope.com
Wed Feb 18 14:43:55 EST 2004


Update of /cvs-repository/ZODB/src/persistent/pickle
In directory cvs.zope.org:/tmp/cvs-serv9977/src/persistent/pickle

Modified Files:
      Tag: zope3-zodb3-devel-branch
	pickle.c 
Log Message:
Fix error checking for PyDict_Next() calls.


=== ZODB/src/persistent/pickle/pickle.c 1.2 => 1.2.10.1 ===
--- ZODB/src/persistent/pickle/pickle.c:1.2	Fri Nov 28 11:44:55 2003
+++ ZODB/src/persistent/pickle/pickle.c	Wed Feb 18 14:43:54 2004
@@ -87,7 +87,7 @@
 {
   PyObject *copy, *key, *value;
   char *ckey;
-  int pos = 0, nr;
+  int pos = 0;
 
   copy = PyDict_New();
   if (copy == NULL)
@@ -96,11 +96,8 @@
   if (state == NULL)
     return copy;
 
-  while ((nr = PyDict_Next(state, &pos, &key, &value))) 
+  while (PyDict_Next(state, &pos, &key, &value))
     {
-      if (nr < 0)
-        goto err;
-
       if (key && PyString_Check(key))
         {
           ckey = PyString_AS_STRING(key);
@@ -111,9 +108,7 @@
             continue;
         }
 
-      if (key != NULL && value != NULL &&
-          (PyObject_SetItem(copy, key, value) < 0)
-          )
+      if (PyObject_SetItem(copy, key, value) < 0)
         goto err;
     }
   
@@ -184,6 +179,7 @@
                 continue;
             }
 
+	  /* XXX will this go through our getattr hook? */
           value = PyObject_GetAttr(self, name);
           if (value == NULL)
             PyErr_Clear();
@@ -191,7 +187,7 @@
             {
               int err = PyDict_SetItem(slots, name, value);
               Py_DECREF(value);
-              if (err)
+              if (err < 0)
                 goto end;
               n++;
             }
@@ -222,9 +218,7 @@
   
   while (PyDict_Next(dict, &pos, &key, &value)) 
     {
-      if (key != NULL && value != NULL &&
-          (PyObject_SetAttr(self, key, value) < 0)
-          )
+      if (PyObject_SetAttr(self, key, value) < 0)
         return -1;
     }
   return 0;




More information about the Zodb-checkins mailing list