]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.14] gh-151126: Sets missing exceptions in `tkinter` and `socket` modules initializ...
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Sat, 27 Jun 2026 15:26:45 +0000 (17:26 +0200)
committerGitHub <noreply@github.com>
Sat, 27 Jun 2026 15:26:45 +0000 (15:26 +0000)
gh-151126: Sets missing exceptions in `tkinter` and `socket` modules initializations (GH-152418)
(cherry picked from commit a9fa8560143098168e0380386acbf4846c37472b)

Co-authored-by: sobolevn <mail@sobolevn.me>
Misc/NEWS.d/next/Library/2026-06-27-17-19-09.gh-issue-151126.huUyOM.rst [new file with mode: 0644]
Modules/_tkinter.c
Modules/socketmodule.c

diff --git a/Misc/NEWS.d/next/Library/2026-06-27-17-19-09.gh-issue-151126.huUyOM.rst b/Misc/NEWS.d/next/Library/2026-06-27-17-19-09.gh-issue-151126.huUyOM.rst
new file mode 100644 (file)
index 0000000..2e51fd4
--- /dev/null
@@ -0,0 +1,2 @@
+Fix two crashes in :mod:`tkinter` and :mod:`socket` modules initialization
+under a memory pressure. Sets missing :exc:`MemoryError`.
index 2153acd2b5633909f2740e06dd83daf6ef7c2d4c..a2a6a789f48937e31af538a485ef773d67d215d1 100644 (file)
@@ -3528,7 +3528,7 @@ PyInit__tkinter(void)
 
     tcl_lock = PyThread_allocate_lock();
     if (tcl_lock == NULL)
-        return NULL;
+        return PyErr_NoMemory();
 
     m = PyModule_Create(&_tkintermodule);
     if (m == NULL)
index e229a99dd0878ec873312a67b7c66818eb857818..73f55ff05742a2573eaca58623f7be410b32ac73 100644 (file)
@@ -9234,6 +9234,7 @@ socket_exec(PyObject *m)
 #if defined(USE_GETHOSTBYNAME_LOCK)
     netdb_lock = PyThread_allocate_lock();
     if (netdb_lock == NULL) {
+        PyErr_NoMemory();
         goto error;
     }
 #endif