https://github.com/python/cpython/commit/51244ba16a7312945a60dff18ed155a581295fbf
commit: 51244ba16a7312945a60dff18ed155a581295fbf
branch: main
author: Bénédikt Tran <[email protected]>
committer: picnixz <[email protected]>
date: 2025-09-03T09:55:53+02:00
summary:
gh-116946: add `Py_TPFLAGS_IMMUTABLETYPE` to `_random.Random` (#138341)
files:
A Misc/NEWS.d/next/Library/2025-09-02-10-23-09.gh-issue-116946.U6RpwK.rst
M Modules/_randommodule.c
diff --git
a/Misc/NEWS.d/next/Library/2025-09-02-10-23-09.gh-issue-116946.U6RpwK.rst
b/Misc/NEWS.d/next/Library/2025-09-02-10-23-09.gh-issue-116946.U6RpwK.rst
new file mode 100644
index 00000000000000..015cf24c8869f8
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2025-09-02-10-23-09.gh-issue-116946.U6RpwK.rst
@@ -0,0 +1,2 @@
+The :class:`!_random.Random` C type is now immutable. Patch by Bénédikt
+Tran.
diff --git a/Modules/_randommodule.c b/Modules/_randommodule.c
index 2f4f388ce1161a..aa2fd28c232f28 100644
--- a/Modules/_randommodule.c
+++ b/Modules/_randommodule.c
@@ -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,
_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: [email protected]