[Python-checkins] bpo-43973: object_set_class() checks Py_TPFLAGS_IMMUTABLETYPE (GH-25714)
vstinner
webhook-mailer at python.org
Fri Apr 30 06:07:10 EDT 2021
https://github.com/python/cpython/commit/b73b5fb9ea08156991a065c1696e8d8cf7622482
commit: b73b5fb9ea08156991a065c1696e8d8cf7622482
branch: master
author: Erlend Egeberg Aasland <erlend.aasland at innova.no>
committer: vstinner <vstinner at python.org>
date: 2021-04-30T12:07:02+02:00
summary:
bpo-43973: object_set_class() checks Py_TPFLAGS_IMMUTABLETYPE (GH-25714)
Use Py_TPFLAGS_IMMUTABLETYPE to check for class assignments.
files:
M Objects/typeobject.c
diff --git a/Objects/typeobject.c b/Objects/typeobject.c
index 19d619fada0e9..1f8e2572a2daf 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;
}
More information about the Python-checkins
mailing list