summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorErlend Egeberg Aasland <erlend.aasland@innova.no>2021-04-30 10:07:02 (GMT)
committerGitHub <noreply@github.com>2021-04-30 10:07:02 (GMT)
commitb73b5fb9ea08156991a065c1696e8d8cf7622482 (patch)
tree6ffde4e950c5badb97bcd6d663e1fcff4ec7cd89 /Objects
parent069e81ab3da46c441335ca762c4333b7bd91861d (diff)
downloadcpython-b73b5fb9ea08156991a065c1696e8d8cf7622482.zip
cpython-b73b5fb9ea08156991a065c1696e8d8cf7622482.tar.gz
cpython-b73b5fb9ea08156991a065c1696e8d8cf7622482.tar.bz2
bpo-43973: object_set_class() checks Py_TPFLAGS_IMMUTABLETYPE (GH-25714)
Use Py_TPFLAGS_IMMUTABLETYPE to check for class assignments.
Diffstat (limited to 'Objects')
-rw-r--r--Objects/typeobject.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/Objects/typeobject.c b/Objects/typeobject.c
index 19d619f..1f8e257 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;
}