mirror of
https://github.com/python/cpython.git
synced 2025-11-27 13:45:25 +00:00
bpo-43973: object_set_class() checks Py_TPFLAGS_IMMUTABLETYPE (GH-25714)
Use Py_TPFLAGS_IMMUTABLETYPE to check for class assignments.
This commit is contained in:
parent
069e81ab3d
commit
b73b5fb9ea
1 changed files with 3 additions and 3 deletions
|
|
@ -4737,10 +4737,10 @@ object_set_class(PyObject *self, PyObject *value, void *closure)
|
||||||
*/
|
*/
|
||||||
if (!(PyType_IsSubtype(newto, &PyModule_Type) &&
|
if (!(PyType_IsSubtype(newto, &PyModule_Type) &&
|
||||||
PyType_IsSubtype(oldto, &PyModule_Type)) &&
|
PyType_IsSubtype(oldto, &PyModule_Type)) &&
|
||||||
(!(newto->tp_flags & Py_TPFLAGS_HEAPTYPE) ||
|
(_PyType_HasFeature(newto, Py_TPFLAGS_IMMUTABLETYPE) ||
|
||||||
!(oldto->tp_flags & Py_TPFLAGS_HEAPTYPE))) {
|
_PyType_HasFeature(oldto, Py_TPFLAGS_IMMUTABLETYPE))) {
|
||||||
PyErr_Format(PyExc_TypeError,
|
PyErr_Format(PyExc_TypeError,
|
||||||
"__class__ assignment only supported for heap types "
|
"__class__ assignment only supported for mutable types "
|
||||||
"or ModuleType subclasses");
|
"or ModuleType subclasses");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue