summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Demo/pysvr/pysvr.c2
-rw-r--r--Python/pythonrun.c10
2 files changed, 7 insertions, 5 deletions
diff --git a/Demo/pysvr/pysvr.c b/Demo/pysvr/pysvr.c
index c651648..b1397c9 100644
--- a/Demo/pysvr/pysvr.c
+++ b/Demo/pysvr/pysvr.c
@@ -168,6 +168,7 @@ main_thread(int port)
PyEval_AcquireThread(gtstate);
gtstate = NULL;
Py_Finalize();
+ Py_Finalize();
}
exit(0);
}
@@ -213,6 +214,7 @@ init_python()
if (gtstate)
return;
Py_Initialize(); /* Initialize the interpreter */
+ Py_Initialize(); /* Initialize the interpreter */
PyEval_InitThreads(); /* Create (and acquire) the interpreter lock */
gtstate = PyEval_SaveThread(); /* Release the thread state */
}
diff --git a/Python/pythonrun.c b/Python/pythonrun.c
index 4d64114..9f977f0 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;