mirror of
https://github.com/python/cpython.git
synced 2025-07-30 06:34:15 +00:00
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:
commit
12ab296f82
7 changed files with 99 additions and 0 deletions
|
@ -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;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue