[Python-checkins] gh-96641: Do not expose `KeyWrapper` in `_functoolsmodule.c` (gh-96642)

corona10 webhook-mailer at python.org
Wed Sep 7 07:13:17 EDT 2022


https://github.com/python/cpython/commit/2fd7246e97c8cc09b4e3f22933693f9d68f08163
commit: 2fd7246e97c8cc09b4e3f22933693f9d68f08163
branch: main
author: Nikita Sobolev <mail at sobolevn.me>
committer: corona10 <donghee.na92 at gmail.com>
date: 2022-09-07T20:13:07+09:00
summary:

gh-96641: Do not expose `KeyWrapper` in `_functoolsmodule.c` (gh-96642)

files:
A Misc/NEWS.d/next/Core and Builtins/2022-09-07-13-38-37.gh-issue-96641.wky0Fc.rst
M Modules/_functoolsmodule.c

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 00000000000..51faca8716f
--- /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 c6d6ca934e9..3abb7fd710a 100644
--- a/Modules/_functoolsmodule.c
+++ b/Modules/_functoolsmodule.c
@@ -1471,9 +1471,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);



More information about the Python-checkins mailing list