diff -r 56f71f02206e Objects/typeobject.c --- a/Objects/typeobject.c Tue Dec 16 18:17:18 2014 -0800 +++ b/Objects/typeobject.c Wed Dec 17 13:59:19 2014 +0200 @@ -3893,10 +3893,29 @@ reduce_newobj(PyObject *obj, int proto) PyObject *newobj, *newargs, *state, *listitems, *dictitems; PyObject *result; + if (Py_TYPE(obj)->tp_new == NULL) { + PyErr_Format(PyExc_TypeError, + "can't pickle %.100s objects", + Py_TYPE(obj)->tp_name); + return NULL; + } if (_PyObject_GetNewArguments(obj, &args, &kwargs) < 0) return NULL; if (args == NULL) { + if (Py_TYPE(obj) != &PyBaseObject_Type && + !(Py_TYPE(obj)->tp_flags & Py_TPFLAGS_HEAPTYPE)) { + _Py_IDENTIFIER(__getstate__); + PyObject *getstate = _PyObject_LookupSpecial(obj, &PyId___getstate__); + if (getstate == NULL) { + PyErr_Format(PyExc_TypeError, + "type '%.200s' does not have __getnewargs_ex__, " + "__getnewargs__ and __getstate__", + Py_TYPE(obj)->tp_name); + return NULL; + } + Py_DECREF(getstate); + } args = PyTuple_New(0); if (args == NULL) { Py_XDECREF(kwargs);