Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit f242aa0

Browse files
committed
Py_Initialize(): Now that standard exceptions are builtin, we don't
need two phase init or fini of the builtin module. Change the call of _PyBuiltin_Init_1() to _PyBuiltin_Init(). Add a call to init_exceptions(). Py_Finalize(): Don't call _PyBuiltin_Fini_1(). Instead call fini_exceptions() but move this to before the thread state is cleared.
1 parent c094ac8 commit f242aa0

1 file changed

Lines changed: 11 additions & 11 deletions

File tree

Python/pythonrun.c

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ Py_Initialize()
152152

153153
_PyCompareState_Key = PyString_InternFromString("cmp_state");
154154

155-
bimod = _PyBuiltin_Init_1();
155+
bimod = _PyBuiltin_Init();
156156
if (bimod == NULL)
157157
Py_FatalError("Py_Initialize: can't initialize __builtin__");
158158
interp->builtins = PyModule_GetDict(bimod);
@@ -170,8 +170,10 @@ Py_Initialize()
170170

171171
_PyImport_Init();
172172

173+
/* initialize builtin exceptions */
174+
init_exceptions();
175+
173176
/* phase 2 of builtins */
174-
_PyBuiltin_Init_2(interp->builtins);
175177
_PyImport_FixupExtension("__builtin__", "__builtin__");
176178

177179
initsigs(); /* Signal handling stuff, including initintr() */
@@ -218,9 +220,6 @@ Py_Finalize()
218220
/* Disable signal handling */
219221
PyOS_FiniInterrupts();
220222

221-
/* Destroy PyExc_MemoryErrorInst */
222-
_PyBuiltin_Fini_1();
223-
224223
/* Cleanup Unicode implementation */
225224
_PyUnicode_Fini();
226225

@@ -252,17 +251,18 @@ Py_Finalize()
252251
}
253252
#endif /* Py_TRACE_REFS */
254253

255-
/* Delete current thread */
256-
PyInterpreterState_Clear(interp);
257-
PyThreadState_Swap(NULL);
258-
PyInterpreterState_Delete(interp);
259-
260254
/* Now we decref the exception classes. After this point nothing
261255
can raise an exception. That's okay, because each Fini() method
262256
below has been checked to make sure no exceptions are ever
263257
raised.
264258
*/
265-
_PyBuiltin_Fini_2();
259+
fini_exceptions();
260+
261+
/* Delete current thread */
262+
PyInterpreterState_Clear(interp);
263+
PyThreadState_Swap(NULL);
264+
PyInterpreterState_Delete(interp);
265+
266266
PyMethod_Fini();
267267
PyFrame_Fini();
268268
PyCFunction_Fini();

0 commit comments

Comments
 (0)