Mercurial > cpython-lru_cache-weakref
comparison Python/pythonrun.c @ 6117:98a282cfb013 legacy-trunk
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.
| author | Guido van Rossum <guido@python.org> |
|---|---|
| date | Wed, 20 Aug 1997 22:40:18 +0000 |
| parents | 2c65bb6ab87c |
| children | 57045f51dd12 |
comparison
equal
deleted
inserted
replaced
| 6116:07b7d4320b14 | 6117:98a282cfb013 |
|---|---|
| 96 PyInterpreterState *interp; | 96 PyInterpreterState *interp; |
| 97 PyThreadState *tstate; | 97 PyThreadState *tstate; |
| 98 PyObject *bimod, *sysmod; | 98 PyObject *bimod, *sysmod; |
| 99 char *p; | 99 char *p; |
| 100 | 100 |
| 101 if (initialized) | 101 if (++initialized > 1) |
| 102 Py_FatalError("Py_Initialize: already initialized"); | 102 return; |
| 103 initialized = 1; | |
| 104 | 103 |
| 105 if ((p = getenv("PYTHONDEBUG")) && *p != '\0') | 104 if ((p = getenv("PYTHONDEBUG")) && *p != '\0') |
| 106 Py_DebugFlag = 1; | 105 Py_DebugFlag = 1; |
| 107 if ((p = getenv("PYTHONVERBOSE")) && *p != '\0') | 106 if ((p = getenv("PYTHONVERBOSE")) && *p != '\0') |
| 108 Py_VerboseFlag = 1; | 107 Py_VerboseFlag = 1; |
| 164 PyInterpreterState *interp; | 163 PyInterpreterState *interp; |
| 165 PyThreadState *tstate; | 164 PyThreadState *tstate; |
| 166 | 165 |
| 167 call_sys_exitfunc(); | 166 call_sys_exitfunc(); |
| 168 | 167 |
| 169 if (!initialized) | 168 if (--initialized > 0) |
| 169 return; | |
| 170 if (initialized < 0) | |
| 170 Py_FatalError("Py_Finalize: not initialized"); | 171 Py_FatalError("Py_Finalize: not initialized"); |
| 171 initialized = 0; | |
| 172 | 172 |
| 173 tstate = PyThreadState_Get(); | 173 tstate = PyThreadState_Get(); |
| 174 interp = tstate->interp; | 174 interp = tstate->interp; |
| 175 | 175 |
| 176 PyImport_Cleanup(); | 176 PyImport_Cleanup(); |
