summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
Diffstat (limited to 'Objects')
-rw-r--r--Objects/typeobject.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/Objects/typeobject.c b/Objects/typeobject.c
index 09c895c..b38e0fb 100644
--- a/Objects/typeobject.c
+++ b/Objects/typeobject.c
@@ -3980,6 +3980,12 @@ reduce_4(PyObject *obj)
PyObject *result;
_Py_IDENTIFIER(__newobj_ex__);
+ 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;
}
@@ -4046,6 +4052,12 @@ reduce_2(PyObject *obj)
Py_ssize_t i, n;
_Py_IDENTIFIER(__newobj__);
+ 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;
}