Skip to content

Commit 3023aaf

Browse files
author
Erlend E. Aasland
committed
Use Py_TPFLAGS_IMMUTABLETYPE to check for class assignments
1 parent 74613a4 commit 3023aaf

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

Objects/typeobject.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4737,10 +4737,10 @@ object_set_class(PyObject *self, PyObject *value, void *closure)
47374737
*/
47384738
if (!(PyType_IsSubtype(newto, &PyModule_Type) &&
47394739
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))) {
47424742
PyErr_Format(PyExc_TypeError,
4743-
"__class__ assignment only supported for heap types "
4743+
"__class__ assignment only supported for mutable types "
47444744
"or ModuleType subclasses");
47454745
return -1;
47464746
}

0 commit comments

Comments
 (0)