Skip to content

Commit f158c0a

Browse files
[3.13] gh-151126: Sets missing exceptions in tkinter and socket modules initializations (GH-152418) (#152422)
gh-151126: Sets missing exceptions in `tkinter` and `socket` modules initializations (GH-152418) (cherry picked from commit a9fa856) Co-authored-by: sobolevn <mail@sobolevn.me>
1 parent a3aa50a commit f158c0a

3 files changed

Lines changed: 4 additions & 1 deletion

File tree

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Fix two crashes in :mod:`tkinter` and :mod:`socket` modules initialization
2+
under a memory pressure. Sets missing :exc:`MemoryError`.

Modules/_tkinter.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3470,7 +3470,7 @@ PyInit__tkinter(void)
34703470

34713471
tcl_lock = PyThread_allocate_lock();
34723472
if (tcl_lock == NULL)
3473-
return NULL;
3473+
return PyErr_NoMemory();
34743474

34753475
m = PyModule_Create(&_tkintermodule);
34763476
if (m == NULL)

Modules/socketmodule.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8942,6 +8942,7 @@ socket_exec(PyObject *m)
89428942
#if defined(USE_GETHOSTBYNAME_LOCK)
89438943
netdb_lock = PyThread_allocate_lock();
89448944
if (netdb_lock == NULL) {
8945+
PyErr_NoMemory();
89458946
goto error;
89468947
}
89478948
#endif

0 commit comments

Comments
 (0)