mirror of
https://github.com/python/cpython.git
synced 2025-07-10 04:45:36 +00:00
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.
This commit is contained in:
parent
558be283bf
commit
aa61505fd2
2 changed files with 7 additions and 5 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue