]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-151126: Sets missing exceptions in `tkinter` and `socket` modules initializations...
authorsobolevn <mail@sobolevn.me>
Sat, 27 Jun 2026 15:00:34 +0000 (18:00 +0300)
committerGitHub <noreply@github.com>
Sat, 27 Jun 2026 15:00:34 +0000 (18:00 +0300)
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 137eba40a762c0ad764316c03fcc7719892101c1..8fa58d07096e30b79088e15d96675a3ee2599f18 100644 (file)
@@ -3574,7 +3574,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 3e82af3194d053aa57056bfadb859d1c552cb885..ada4fda6571049d4e62b81ac40bedb7fccef3ceb 100644 (file)
@@ -9296,6 +9296,7 @@ socket_exec(PyObject *m)
 #if defined(USE_GETHOSTBYNAME_LOCK)
     netdb_lock = PyThread_allocate_lock();
     if (netdb_lock == NULL) {
+        PyErr_NoMemory();
         goto error;
     }
 #endif