[Zodb-checkins] CVS: Zope/lib/python/persistent/pickle -
pickle.c:1.3
Jeremy Hylton
jeremy at zope.com
Wed Feb 18 22:00:07 EST 2004
Update of /cvs-repository/Zope/lib/python/persistent/pickle
In directory cvs.zope.org:/tmp/cvs-serv12124/lib/python/persistent/pickle
Modified Files:
pickle.c
Log Message:
Merge zope3-zodb3-devel-branch to the Zope head (Zope 2 head).
Added support for persistent weak references and
PersistentWeakKeyDictionary.
Add _p_invalidate() method to persistence API. _p_deactivate() is
advisory from the cache. _p_invalidate() is called when database
invalidates object.
Port support for getattr/setattr hacks from ZODB4. The doctest tests
describe the new technique pretty well.
Remove unused arguments from some cPickleCache calls.
=== Zope/lib/python/persistent/pickle/pickle.c 1.2 => 1.3 ===
--- Zope/lib/python/persistent/pickle/pickle.c:1.2 Fri Nov 28 11:44:55 2003
+++ Zope/lib/python/persistent/pickle/pickle.c Wed Feb 18 21:59:31 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