rejects builtin types with not defined __new__.
Core and Builtins
-----------------
+- Issue #22995: Default implementation of __reduce__ and __reduce_ex__ now
+ rejects builtin types with not defined __new__.
+
- Issue #7267: format(int, 'c') now raises OverflowError when the argument is
not in range(0, 256).
if (cls == NULL)
return NULL;
+ if (PyType_Check(cls) && ((PyTypeObject *)cls)->tp_new == NULL) {
+ PyErr_Format(PyExc_TypeError,
+ "can't pickle %s objects",
+ ((PyTypeObject *)cls)->tp_name);
+ return NULL;
+ }
+
getnewargs = PyObject_GetAttrString(obj, "__getnewargs__");
if (getnewargs != NULL) {
args = PyObject_CallObject(getnewargs, NULL);