[Python-checkins] python/dist/src/Modules cPickle.c,2.86,2.87
jhylton@users.sourceforge.net
jhylton@users.sourceforge.net
Thu, 11 Jul 2002 15:01:44 -0700
Update of /cvsroot/python/python/dist/src/Modules
In directory usw-pr-cvs1:/tmp/cvs-serv5524
Modified Files:
cPickle.c
Log Message:
Do more robust test of whether global objects are accessible.
PyImport_ImportModule() is not guaranteed to return a module object.
When another type of object was returned, the PyModule_GetDict() call
return NULL and the subsequent GetItem() seg faulted.
Bug fix candidate.
Index: cPickle.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Modules/cPickle.c,v
retrieving revision 2.86
retrieving revision 2.87
diff -C2 -d -r2.86 -r2.87
*** cPickle.c 26 Jun 2002 20:40:42 -0000 2.86
--- cPickle.c 11 Jul 2002 22:01:40 -0000 2.87
***************
*** 1720,1727 ****
goto finally;
}
! /* borrowed ref */
! moddict = PyModule_GetDict(mod);
! /* borrowed ref */
! klass = PyDict_GetItemString(moddict, name_str);
if (klass == NULL) {
cPickle_ErrFormat(PicklingError,
--- 1720,1724 ----
goto finally;
}
! klass = PyObject_GetAttrString(mod, name_str);
if (klass == NULL) {
cPickle_ErrFormat(PicklingError,
***************
*** 1731,1734 ****
--- 1728,1732 ----
}
if (klass != args) {
+ Py_DECREF(klass);
cPickle_ErrFormat(PicklingError,
"Can't pickle %s: it's not the same object as %s.%s",
***************
*** 1736,1739 ****
--- 1734,1738 ----
goto finally;
}
+ Py_DECREF(klass);
if ((*self->write_func)(self, &global, 1) < 0)