comparison Python/pythonrun.c @ 12754:5213abfe5230 legacy-trunk

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.
author Barry Warsaw <barry@python.org>
date Thu, 25 May 2000 23:09:49 +0000
parents 1c7c2dd1beb1
children 63436719d12e
comparison
equal deleted inserted replaced
12753:86ec75dac272 12754:5213abfe5230
150 /* Init Unicode implementation; relies on the codec registry */ 150 /* Init Unicode implementation; relies on the codec registry */
151 _PyUnicode_Init(); 151 _PyUnicode_Init();
152 152
153 _PyCompareState_Key = PyString_InternFromString("cmp_state"); 153 _PyCompareState_Key = PyString_InternFromString("cmp_state");
154 154
155 bimod = _PyBuiltin_Init_1(); 155 bimod = _PyBuiltin_Init();
156 if (bimod == NULL) 156 if (bimod == NULL)
157 Py_FatalError("Py_Initialize: can't initialize __builtin__"); 157 Py_FatalError("Py_Initialize: can't initialize __builtin__");
158 interp->builtins = PyModule_GetDict(bimod); 158 interp->builtins = PyModule_GetDict(bimod);
159 Py_INCREF(interp->builtins); 159 Py_INCREF(interp->builtins);
160 160
168 PyDict_SetItemString(interp->sysdict, "modules", 168 PyDict_SetItemString(interp->sysdict, "modules",
169 interp->modules); 169 interp->modules);
170 170
171 _PyImport_Init(); 171 _PyImport_Init();
172 172
173 /* initialize builtin exceptions */
174 init_exceptions();
175
173 /* phase 2 of builtins */ 176 /* phase 2 of builtins */
174 _PyBuiltin_Init_2(interp->builtins);
175 _PyImport_FixupExtension("__builtin__", "__builtin__"); 177 _PyImport_FixupExtension("__builtin__", "__builtin__");
176 178
177 initsigs(); /* Signal handling stuff, including initintr() */ 179 initsigs(); /* Signal handling stuff, including initintr() */
178 180
179 initmain(); /* Module __main__ */ 181 initmain(); /* Module __main__ */
215 tstate = PyThreadState_Get(); 217 tstate = PyThreadState_Get();
216 interp = tstate->interp; 218 interp = tstate->interp;
217 219
218 /* Disable signal handling */ 220 /* Disable signal handling */
219 PyOS_FiniInterrupts(); 221 PyOS_FiniInterrupts();
220
221 /* Destroy PyExc_MemoryErrorInst */
222 _PyBuiltin_Fini_1();
223 222
224 /* Cleanup Unicode implementation */ 223 /* Cleanup Unicode implementation */
225 _PyUnicode_Fini(); 224 _PyUnicode_Fini();
226 225
227 /* Cleanup Codec registry */ 226 /* Cleanup Codec registry */
250 _Py_AskYesNo("Print left references?")) { 249 _Py_AskYesNo("Print left references?")) {
251 _Py_PrintReferences(stderr); 250 _Py_PrintReferences(stderr);
252 } 251 }
253 #endif /* Py_TRACE_REFS */ 252 #endif /* Py_TRACE_REFS */
254 253
255 /* Delete current thread */
256 PyInterpreterState_Clear(interp);
257 PyThreadState_Swap(NULL);
258 PyInterpreterState_Delete(interp);
259
260 /* Now we decref the exception classes. After this point nothing 254 /* Now we decref the exception classes. After this point nothing
261 can raise an exception. That's okay, because each Fini() method 255 can raise an exception. That's okay, because each Fini() method
262 below has been checked to make sure no exceptions are ever 256 below has been checked to make sure no exceptions are ever
263 raised. 257 raised.
264 */ 258 */
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
266 PyMethod_Fini(); 266 PyMethod_Fini();
267 PyFrame_Fini(); 267 PyFrame_Fini();
268 PyCFunction_Fini(); 268 PyCFunction_Fini();
269 PyTuple_Fini(); 269 PyTuple_Fini();
270 PyString_Fini(); 270 PyString_Fini();