Core and Builtins
-----------------
+- Issue #25961: Disallowed null characters in the type name.
+
- Issue #22995: Instances of extension types with a state that aren't
subclasses of list or dict and haven't implemented any pickle-related
methods (__reduce__, __reduce_ex__, __getnewargs__, __getnewargs_ex__,
}
if (strlen(PyString_AS_STRING(value))
!= (size_t)PyString_GET_SIZE(value)) {
- PyErr_Format(PyExc_ValueError,
- "__name__ must not contain null bytes");
+ PyErr_SetString(PyExc_ValueError,
+ "type name must not contain null characters");
return -1;
}
PyTypeObject *type, *base, *tmptype, *winner;
PyHeapTypeObject *et;
PyMemberDef *mp;
- Py_ssize_t i, nbases, nslots, slotoffset, add_dict, add_weak;
- int j, may_add_dict, may_add_weak;
+ Py_ssize_t i, nbases, nslots, slotoffset;
+ int j, may_add_dict, may_add_weak, add_dict, add_weak;
assert(args != NULL && PyTuple_Check(args));
assert(kwds == NULL || PyDict_Check(kwds));
type->tp_as_mapping = &et->as_mapping;
type->tp_as_buffer = &et->as_buffer;
type->tp_name = PyString_AS_STRING(name);
+ if (!type->tp_name)
+ goto error;
+ if (strlen(type->tp_name) != (size_t)PyString_GET_SIZE(name)) {
+ PyErr_SetString(PyExc_ValueError,
+ "type name must not contain null characters");
+ goto error;
+ }
/* Set tp_base and tp_bases */
type->tp_bases = bases;