Skip to content

Commit 592575c

Browse files
[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 a9fa856) Co-authored-by: sobolevn <mail@sobolevn.me>
1 parent 2c7e890 commit 592575c

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
@@ -3574,7 +3574,7 @@ PyInit__tkinter(void)
35743574

35753575
tcl_lock = PyThread_allocate_lock();
35763576
if (tcl_lock == NULL)
3577-
return NULL;
3577+
return PyErr_NoMemory();
35783578

35793579
m = PyModule_Create(&_tkintermodule);
35803580
if (m == NULL)

Modules/socketmodule.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9288,6 +9288,7 @@ socket_exec(PyObject *m)
92889288
#if defined(USE_GETHOSTBYNAME_LOCK)
92899289
netdb_lock = PyThread_allocate_lock();
92909290
if (netdb_lock == NULL) {
9291+
PyErr_NoMemory();
92919292
goto error;
92929293
}
92939294
#endif

0 commit comments

Comments
 (0)