summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorErlend Egeberg Aasland <erlend.aasland@innova.no>2022-01-07 14:08:19 (GMT)
committerGitHub <noreply@github.com>2022-01-07 14:08:19 (GMT)
commitb127e70a8a682fe869c22ce04c379bd85a00db67 (patch)
treefae781cf9ba18cf875818b09a0c02b8ae8a0188e /Modules
parent994f90c0772612780361e1dc5fa5223dce22f70a (diff)
downloadcpython-b127e70a8a682fe869c22ce04c379bd85a00db67.zip
cpython-b127e70a8a682fe869c22ce04c379bd85a00db67.tar.gz
cpython-b127e70a8a682fe869c22ce04c379bd85a00db67.tar.bz2
bpo-46070: Fix asyncio initialisation guard (GH-30423)
If init flag is set, exit successfully immediately. If not, only set the flag after successful initialization.
Diffstat (limited to 'Modules')
-rw-r--r--Modules/_asynciomodule.c10
1 files changed, 4 insertions, 6 deletions
diff --git a/Modules/_asynciomodule.c b/Modules/_asynciomodule.c
index 978a1fd..b08a7d1 100644
--- a/Modules/_asynciomodule.c
+++ b/Modules/_asynciomodule.c
@@ -3318,17 +3318,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) {
@@ -3389,6 +3386,7 @@ module_init(void)
goto fail;
}
+ module_initialized = 1;
Py_DECREF(module);
return 0;