File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -168,6 +168,7 @@ main_thread(int port)
168168 PyEval_AcquireThread (gtstate );
169169 gtstate = NULL ;
170170 Py_Finalize ();
171+ Py_Finalize ();
171172 }
172173 exit (0 );
173174}
@@ -213,6 +214,7 @@ init_python()
213214 if (gtstate )
214215 return ;
215216 Py_Initialize (); /* Initialize the interpreter */
217+ Py_Initialize (); /* Initialize the interpreter */
216218 PyEval_InitThreads (); /* Create (and acquire) the interpreter lock */
217219 gtstate = PyEval_SaveThread (); /* Release the thread state */
218220}
Original file line number Diff line number Diff line change @@ -98,9 +98,8 @@ Py_Initialize()
9898 PyObject * bimod , * sysmod ;
9999 char * p ;
100100
101- if (initialized )
102- Py_FatalError ("Py_Initialize: already initialized" );
103- initialized = 1 ;
101+ if (++ initialized > 1 )
102+ return ;
104103
105104 if ((p = getenv ("PYTHONDEBUG" )) && * p != '\0' )
106105 Py_DebugFlag = 1 ;
@@ -166,9 +165,10 @@ Py_Finalize()
166165
167166 call_sys_exitfunc ();
168167
169- if (!initialized )
168+ if (-- initialized > 0 )
169+ return ;
170+ if (initialized < 0 )
170171 Py_FatalError ("Py_Finalize: not initialized" );
171- initialized = 0 ;
172172
173173 tstate = PyThreadState_Get ();
174174 interp = tstate -> interp ;
You can’t perform that action at this time.
0 commit comments