bpo-43973: object_set_class() checks Py_TPFLAGS_IMMUTABLETYPE (GH-25… · python/cpython@b73b5fb (original) (raw)

Original file line number Diff line number Diff line change
@@ -4737,10 +4737,10 @@ object_set_class(PyObject *self, PyObject *value, void *closure)
4737 4737 */
4738 4738 if (!(PyType_IsSubtype(newto, &PyModule_Type) &&
4739 4739 PyType_IsSubtype(oldto, &PyModule_Type)) &&
4740 - (!(newto->tp_flags & Py_TPFLAGS_HEAPTYPE) |
4741 -!(oldto->tp_flags & Py_TPFLAGS_HEAPTYPE))) {
4740 + (_PyType_HasFeature(newto, Py_TPFLAGS_IMMUTABLETYPE) |
4741 +_PyType_HasFeature(oldto, Py_TPFLAGS_IMMUTABLETYPE))) {
4742 4742 PyErr_Format(PyExc_TypeError,
4743 -"__class__ assignment only supported for heap types "
4743 +"__class__ assignment only supported for mutable types "
4744 4744 "or ModuleType subclasses");
4745 4745 return -1;
4746 4746 }