Issue #22995: Default implementation of __reduce__ and __reduce_ex__ now

rejects builtin types with not defined __new__.
Added tests for non-pickleable types.
This commit is contained in:
Serhiy Storchaka 2015-11-12 11:34:39 +02:00
commit 12ab296f82
7 changed files with 99 additions and 0 deletions

View file

@ -4108,6 +4108,12 @@ reduce_newobj(PyObject *obj)
PyObject *newobj, *newargs, *state, *listitems, *dictitems;
PyObject *result;
if (Py_TYPE(obj)->tp_new == NULL) {
PyErr_Format(PyExc_TypeError,
"can't pickle %s objects",
Py_TYPE(obj)->tp_name);
return NULL;
}
if (_PyObject_GetNewArguments(obj, &args, &kwargs) < 0)
return NULL;