Skip to content

Commit 51244ba

Browse files
authored
gh-116946: add Py_TPFLAGS_IMMUTABLETYPE to _random.Random (#138341)
1 parent dd86fb4 commit 51244ba

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
The :class:`!_random.Random` C type is now immutable. Patch by Bénédikt
2+
Tran.

Modules/_randommodule.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -595,11 +595,14 @@ static PyType_Slot Random_Type_slots[] = {
595595
};
596596

597597
static PyType_Spec Random_Type_spec = {
598-
"_random.Random",
599-
sizeof(RandomObject),
600-
0,
601-
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
602-
Random_Type_slots
598+
.name = "_random.Random",
599+
.basicsize = sizeof(RandomObject),
600+
.flags = (
601+
Py_TPFLAGS_DEFAULT
602+
| Py_TPFLAGS_BASETYPE
603+
| Py_TPFLAGS_IMMUTABLETYPE
604+
),
605+
.slots = Random_Type_slots
603606
};
604607

605608
PyDoc_STRVAR(module_doc,

0 commit comments

Comments
 (0)