gh-116946: add Py_TPFLAGS_IMMUTABLETYPE to _random.Random (#138341)

This commit is contained in:
Bénédikt Tran 2025-09-03 09:55:53 +02:00 committed by GitHub
parent dd86fb4ba5
commit 51244ba16a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 10 additions and 5 deletions

View file

@ -0,0 +1,2 @@
The :class:`!_random.Random` C type is now immutable. Patch by Bénédikt
Tran.

View file

@ -595,11 +595,14 @@ static PyType_Slot Random_Type_slots[] = {
};
static PyType_Spec Random_Type_spec = {
"_random.Random",
sizeof(RandomObject),
0,
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
Random_Type_slots
.name = "_random.Random",
.basicsize = sizeof(RandomObject),
.flags = (
Py_TPFLAGS_DEFAULT
| Py_TPFLAGS_BASETYPE
| Py_TPFLAGS_IMMUTABLETYPE
),
.slots = Random_Type_slots
};
PyDoc_STRVAR(module_doc,