diff --git a/Include/object.h b/Include/object.h index 695f015642..66e48cb0be 100644 --- a/Include/object.h +++ b/Include/object.h @@ -320,6 +320,9 @@ Code can use PyType_HasFeature(type_ob, flag_value) to test whether the given type object has a specified feature. */ +/* Set if the type object if immutable */ +#define Py_TPFLAGS_IMMUTABLE (1UL tp_flags & Py_TPFLAGS_HEAPTYPE)) { + if (!(type->tp_flags & Py_TPFLAGS_HEAPTYPE) || + type->tp_flags & Py_TPFLAGS_IMMUTABLE) + { PyErr_Format( PyExc_TypeError, "can't set attributes of built-in/extension type '%s'",