[3.15] gh-151126: Sets missing exceptions in tkinter and socket modules initializations (GH-152418) (#152420)

gh-151126: Sets missing exceptions in `tkinter` and `socket` modules initializations (GH-152418)
(cherry picked from commit a9fa856014)

Co-authored-by: sobolevn <mail@sobolevn.me>
This commit is contained in:
Miss Islington (bot) 2026-06-27 17:28:27 +02:00 committed by GitHub
parent 2c7e8908cd
commit 592575ca7a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 4 additions and 1 deletions

View file

@ -0,0 +1,2 @@
Fix two crashes in :mod:`tkinter` and :mod:`socket` modules initialization
under a memory pressure. Sets missing :exc:`MemoryError`.

View 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)

View file

@ -9288,6 +9288,7 @@ socket_exec(PyObject *m)
#if defined(USE_GETHOSTBYNAME_LOCK)
netdb_lock = PyThread_allocate_lock();
if (netdb_lock == NULL) {
PyErr_NoMemory();
goto error;
}
#endif