Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Use Py_TPFLAGS_IMMUTABLETYPE to check for class assignments
  • Loading branch information
Erlend E. Aasland committed Apr 30, 2021
commit 3023aaf84dc9f888652932608382b390890c46d1
6 changes: 3 additions & 3 deletions Objects/typeobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 "
Comment thread
vstinner marked this conversation as resolved.
Outdated
"or ModuleType subclasses");
return -1;
}
Expand Down