[Python-checkins] bpo-32604: Fix reference leak in select module (GH-20600)

Victor Stinner webhook-mailer at python.org
Wed Jun 3 08:36:56 EDT 2020


https://github.com/python/cpython/commit/18a90248fdd92b27098cc4db773686a2d10a4d24
commit: 18a90248fdd92b27098cc4db773686a2d10a4d24
branch: master
author: Victor Stinner <vstinner at python.org>
committer: GitHub <noreply at github.com>
date: 2020-06-03T14:36:46+02:00
summary:

bpo-32604: Fix reference leak in select module (GH-20600)

Fix reference leak in PyInit_select() of the select module:
remove Py_INCREF(poll_Type).

files:
A Misc/NEWS.d/next/Library/2020-06-02-23-49-07.bpo-32604.ZN4V4l.rst
M Modules/selectmodule.c

diff --git a/Misc/NEWS.d/next/Library/2020-06-02-23-49-07.bpo-32604.ZN4V4l.rst b/Misc/NEWS.d/next/Library/2020-06-02-23-49-07.bpo-32604.ZN4V4l.rst
new file mode 100644
index 0000000000000..6375276602e4a
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2020-06-02-23-49-07.bpo-32604.ZN4V4l.rst
@@ -0,0 +1,2 @@
+Fix reference leak in the :mod:`select` module when the the module is
+imported in a subinterpreter.
diff --git a/Modules/selectmodule.c b/Modules/selectmodule.c
index 04e0067eec218..adf014fac43d4 100644
--- a/Modules/selectmodule.c
+++ b/Modules/selectmodule.c
@@ -2482,7 +2482,6 @@ PyInit_select(void)
         if (poll_Type == NULL)
             return NULL;
         get_select_state(m)->poll_Type = (PyTypeObject *)poll_Type;
-        Py_INCREF(poll_Type);
 
         PyModule_AddIntMacro(m, POLLIN);
         PyModule_AddIntMacro(m, POLLPRI);
@@ -2518,7 +2517,6 @@ PyInit_select(void)
     if (devpoll_Type == NULL)
         return NULL;
     get_select_state(m)->devpoll_Type = (PyTypeObject *)devpoll_Type;
-    Py_INCREF(devpoll_Type);
 #endif
 
 #ifdef HAVE_EPOLL



More information about the Python-checkins mailing list