diff --git a/Objects/typeobject.c b/Objects/typeobject.c index 209d4fab1f6..ae593636e6c 100644 --- a/Objects/typeobject.c +++ b/Objects/typeobject.c @@ -4263,7 +4263,7 @@ reduce_newobj(PyObject *obj) } Py_XDECREF(args); } - else { + else if (args != NULL) { _Py_IDENTIFIER(__newobj_ex__); newobj = _PyObject_GetAttrId(copyreg, &PyId___newobj_ex__); @@ -4281,6 +4281,12 @@ reduce_newobj(PyObject *obj) return NULL; } } + else { + /* args == NULL */ + Py_DECREF(kwargs); + PyErr_BadInternalCall(); + return NULL; + } state = _PyObject_GetState(obj, !hasargs && !PyList_Check(obj) && !PyDict_Check(obj));