Issue #7689: Allow pickling of dynamically created classes when their

metaclass is registered with copyreg.  Patch by Nicolas M. Thiéry and
Craig Citro.
This commit is contained in:
Antoine Pitrou 2011-10-04 09:25:28 +02:00
commit 5a688dbf97
5 changed files with 40 additions and 13 deletions

View file

@ -3134,10 +3134,6 @@ save(PicklerObject *self, PyObject *obj, int pers_save)
status = save_global(self, obj, NULL);
goto done;
}
else if (PyType_IsSubtype(type, &PyType_Type)) {
status = save_global(self, obj, NULL);
goto done;
}
/* XXX: This part needs some unit tests. */
@ -3156,6 +3152,10 @@ save(PicklerObject *self, PyObject *obj, int pers_save)
Py_INCREF(obj);
reduce_value = _Pickler_FastCall(self, reduce_func, obj);
}
else if (PyType_IsSubtype(type, &PyType_Type)) {
status = save_global(self, obj, NULL);
goto done;
}
else {
static PyObject *reduce_str = NULL;
static PyObject *reduce_ex_str = NULL;