made cPickle fall back to the copy_reg/reduce protocol,

if a function cannot be stored as global.
This is for compatibility with pickle.py .
This commit is contained in:
Christian Tismer 2004-02-26 16:21:45 +00:00
parent d594849c42
commit 2460c62152
1 changed files with 5 additions and 0 deletions

View File

@ -2418,6 +2418,11 @@ save(Picklerobject *self, PyObject *args, int pers_save)
case 'f':
if (type == &PyFunction_Type) {
res = save_global(self, args, NULL);
if (res && PyErr_ExceptionMatches(PickleError)) {
/* fall back to reduce */
PyErr_Clear();
break;
}
goto finally;
}
break;