summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2015-10-10 19:42:18 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2015-10-10 19:42:18 (GMT)
commit0d554d7ef159761439ade414fcd028262eae656c (patch)
tree11aa1a1dfd3cfa07302f98d6b7b7409e9354d568 /Objects
parent4e96df3b595ed87957ee12e86e49f63b2d1cd05f (diff)
downloadcpython-0d554d7ef159761439ade414fcd028262eae656c.zip
cpython-0d554d7ef159761439ade414fcd028262eae656c.tar.gz
cpython-0d554d7ef159761439ade414fcd028262eae656c.tar.bz2
Issue #24164: Objects that need calling ``__new__`` with keyword arguments,
can now be pickled using pickle protocols older than protocol version 4.
Diffstat (limited to 'Objects')
-rw-r--r--Objects/typeobject.c16
1 files changed, 3 insertions, 13 deletions
diff --git a/Objects/typeobject.c b/Objects/typeobject.c
index 4b091f5..bf0d30c 100644
--- a/Objects/typeobject.c
+++ b/Objects/typeobject.c
@@ -4101,7 +4101,7 @@ _PyObject_GetItemsIter(PyObject *obj, PyObject **listitems,
}
static PyObject *
-reduce_newobj(PyObject *obj, int proto)
+reduce_newobj(PyObject *obj)
{
PyObject *args = NULL, *kwargs = NULL;
PyObject *copyreg;
@@ -4153,7 +4153,7 @@ reduce_newobj(PyObject *obj, int proto)
}
Py_DECREF(args);
}
- else if (proto >= 4) {
+ else {
_Py_IDENTIFIER(__newobj_ex__);
newobj = _PyObject_GetAttrId(copyreg, &PyId___newobj_ex__);
@@ -4171,16 +4171,6 @@ reduce_newobj(PyObject *obj, int proto)
return NULL;
}
}
- else {
- PyErr_SetString(PyExc_ValueError,
- "must use protocol 4 or greater to copy this "
- "object; since __getnewargs_ex__ returned "
- "keyword arguments.");
- Py_DECREF(args);
- Py_DECREF(kwargs);
- Py_DECREF(copyreg);
- return NULL;
- }
state = _PyObject_GetState(obj);
if (state == NULL) {
@@ -4225,7 +4215,7 @@ _common_reduce(PyObject *self, int proto)
PyObject *copyreg, *res;
if (proto >= 2)
- return reduce_newobj(self, proto);
+ return reduce_newobj(self);
copyreg = import_copyreg();
if (!copyreg)