bpo-43908: Add Py_TPFLAGS_IMMUTABLETYPE flag (GH-25520)

Introduce Py_TPFLAGS_IMMUTABLETYPE flag for immutable type objects, and
modify PyType_Ready() to set it for static types.

Co-authored-by: Victor Stinner <vstinner@python.org>
This commit is contained in:
Erlend Egeberg Aasland 2021-04-28 19:02:42 +02:00 committed by GitHub
parent 3cc481b9de
commit 3b52c8d66b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 24 additions and 1 deletions

View file

@ -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 is immutable: type attributes cannot be set nor deleted */
#define Py_TPFLAGS_IMMUTABLETYPE (1UL << 8)
/* Set if the type object is dynamically allocated */
#define Py_TPFLAGS_HEAPTYPE (1UL << 9)