Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Fix possible segfault when importing the :mod:`asyncio` module from
different sub-interpreters in parallel. Patch by Erlend E. Aasland.
10 changes: 4 additions & 6 deletions Modules/_asynciomodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -3309,17 +3309,14 @@ static int
module_init(void)
{
PyObject *module = NULL;
if (module_initialized) {
return 0;
}

asyncio_mod = PyImport_ImportModule("asyncio");
if (asyncio_mod == NULL) {
goto fail;
}
if (module_initialized != 0) {
return 0;
}
else {
module_initialized = 1;
}

current_tasks = PyDict_New();
if (current_tasks == NULL) {
Expand Down Expand Up @@ -3380,6 +3377,7 @@ module_init(void)
goto fail;
}

module_initialized = 1;
Py_DECREF(module);
return 0;

Expand Down