From 3023aaf84dc9f888652932608382b390890c46d1 Mon Sep 17 00:00:00 2001 From: "Erlend E. Aasland" Date: Thu, 29 Apr 2021 10:30:06 +0200 Subject: [PATCH] Use Py_TPFLAGS_IMMUTABLETYPE to check for class assignments --- Objects/typeobject.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Objects/typeobject.c b/Objects/typeobject.c index ac4dc1da4411dc..b23d44412a3f08 100644 --- a/Objects/typeobject.c +++ b/Objects/typeobject.c @@ -4737,10 +4737,10 @@ object_set_class(PyObject *self, PyObject *value, void *closure) */ if (!(PyType_IsSubtype(newto, &PyModule_Type) && PyType_IsSubtype(oldto, &PyModule_Type)) && - (!(newto->tp_flags & Py_TPFLAGS_HEAPTYPE) || - !(oldto->tp_flags & Py_TPFLAGS_HEAPTYPE))) { + (_PyType_HasFeature(newto, Py_TPFLAGS_IMMUTABLETYPE) || + _PyType_HasFeature(oldto, Py_TPFLAGS_IMMUTABLETYPE))) { PyErr_Format(PyExc_TypeError, - "__class__ assignment only supported for heap types " + "__class__ assignment only supported for mutable types " "or ModuleType subclasses"); return -1; }