summaryrefslogtreecommitdiff
path: root/Python/pythonrun.c
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1997-08-20 22:40:18 +0000
committerGuido van Rossum <guido@python.org>1997-08-20 22:40:18 +0000
commit61a3b9bcb44b0052a8e9fc4431548b0a9a4d7648 (patch)
tree9f6546770bb760b7d4f68e3a76e938b6415254b0 /Python/pythonrun.c
parent154eec968e3b02c06ea885aa84e5435e4f271748 (diff)
downloadcpython-61a3b9bcb44b0052a8e9fc4431548b0a9a4d7648.tar.gz
Use a counter instead of a Boolean to check for initialized; n calls
to Py_Initialize will be undone by n calls to Py_Uninitialize.
Diffstat (limited to 'Python/pythonrun.c')
-rw-r--r--Python/pythonrun.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/Python/pythonrun.c b/Python/pythonrun.c
index 4d64114671..9f977f05b4 100644
--- a/Python/pythonrun.c
+++ b/Python/pythonrun.c
@@ -98,9 +98,8 @@ Py_Initialize()
PyObject *bimod, *sysmod;
char *p;
- if (initialized)
- Py_FatalError("Py_Initialize: already initialized");
- initialized = 1;
+ if (++initialized > 1)
+ return;
if ((p = getenv("PYTHONDEBUG")) && *p != '\0')
Py_DebugFlag = 1;
@@ -166,9 +165,10 @@ Py_Finalize()
call_sys_exitfunc();
- if (!initialized)
+ if (--initialized > 0)
+ return;
+ if (initialized < 0)
Py_FatalError("Py_Finalize: not initialized");
- initialized = 0;
tstate = PyThreadState_Get();
interp = tstate->interp;