summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2022-09-07 11:50:15 (GMT)
committerGitHub <noreply@github.com>2022-09-07 11:50:15 (GMT)
commiteecbb54b620128421b2a5e57f0ec68ba2514abec (patch)
tree0829ad5af09437815ec12a683629dc29d1667971
parentb6af9337163e03cc853aa15905658748abef0901 (diff)
downloadcpython-eecbb54b620128421b2a5e57f0ec68ba2514abec.zip
cpython-eecbb54b620128421b2a5e57f0ec68ba2514abec.tar.gz
cpython-eecbb54b620128421b2a5e57f0ec68ba2514abec.tar.bz2
gh-96641: Do not expose `KeyWrapper` in `_functoolsmodule.c` (gh-96642)
(cherry picked from commit 2fd7246e97c8cc09b4e3f22933693f9d68f08163) Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
-rw-r--r--Misc/NEWS.d/next/Core and Builtins/2022-09-07-13-38-37.gh-issue-96641.wky0Fc.rst1
-rw-r--r--Modules/_functoolsmodule.c5
2 files changed, 3 insertions, 3 deletions
diff --git a/Misc/NEWS.d/next/Core and Builtins/2022-09-07-13-38-37.gh-issue-96641.wky0Fc.rst b/Misc/NEWS.d/next/Core and Builtins/2022-09-07-13-38-37.gh-issue-96641.wky0Fc.rst
new file mode 100644
index 0000000..51faca8
--- /dev/null
+++ b/Misc/NEWS.d/next/Core and Builtins/2022-09-07-13-38-37.gh-issue-96641.wky0Fc.rst
@@ -0,0 +1 @@
+Do not expose ``KeyWrapper`` in :mod:`_functools`.
diff --git a/Modules/_functoolsmodule.c b/Modules/_functoolsmodule.c
index fa14521..6ad0990 100644
--- a/Modules/_functoolsmodule.c
+++ b/Modules/_functoolsmodule.c
@@ -1470,9 +1470,8 @@ _functools_exec(PyObject *module)
if (state->keyobject_type == NULL) {
return -1;
}
- if (PyModule_AddType(module, state->keyobject_type) < 0) {
- return -1;
- }
+ // keyobject_type is used only internally.
+ // So we don't expose it in module namespace.
state->lru_list_elem_type = (PyTypeObject *)PyType_FromModuleAndSpec(
module, &lru_list_elem_type_spec, NULL);