comparison Python/pythonrun.c @ 27958:e07b21ea3c45 legacy-trunk

Fix bug 683658 - PyErr_Warn may cause import deadlock.
author Mark Hammond <mhammond@skippinet.com.au>
date Wed, 19 Feb 2003 00:33:33 +0000
parents be7683a6f521
children c61ef183ce2f
comparison
equal deleted inserted replaced
27957:91fc9637e56a 27958:e07b21ea3c45
58 /* _XXX Py_QnewFlag should go away in 2.3. It's true iff -Qnew is passed, 58 /* _XXX Py_QnewFlag should go away in 2.3. It's true iff -Qnew is passed,
59 on the command line, and is used in 2.2 by ceval.c to make all "/" divisions 59 on the command line, and is used in 2.2 by ceval.c to make all "/" divisions
60 true divisions (which they will be in 2.3). */ 60 true divisions (which they will be in 2.3). */
61 int _Py_QnewFlag = 0; 61 int _Py_QnewFlag = 0;
62 62
63 /* Reference to 'warnings' module, to avoid importing it
64 on the fly when the import lock may be held. See 683658
65 */
66 PyObject *PyModule_WarningsModule = NULL;
67
63 static int initialized = 0; 68 static int initialized = 0;
64 69
65 /* API to access the initialized flag -- useful for esoteric use */ 70 /* API to access the initialized flag -- useful for esoteric use */
66 71
67 int 72 int
166 171
167 /* phase 2 of builtins */ 172 /* phase 2 of builtins */
168 _PyImport_FixupExtension("__builtin__", "__builtin__"); 173 _PyImport_FixupExtension("__builtin__", "__builtin__");
169 174
170 _PyImportHooks_Init(); 175 _PyImportHooks_Init();
176
177 PyModule_WarningsModule = PyImport_ImportModule("warnings");
171 178
172 initsigs(); /* Signal handling stuff, including initintr() */ 179 initsigs(); /* Signal handling stuff, including initintr() */
173 180
174 initmain(); /* Module __main__ */ 181 initmain(); /* Module __main__ */
175 if (!Py_NoSiteFlag) 182 if (!Py_NoSiteFlag)
222 /* Disable signal handling */ 229 /* Disable signal handling */
223 PyOS_FiniInterrupts(); 230 PyOS_FiniInterrupts();
224 231
225 /* Cleanup Codec registry */ 232 /* Cleanup Codec registry */
226 _PyCodecRegistry_Fini(); 233 _PyCodecRegistry_Fini();
234
235 /* drop module references we saved */
236 Py_XDECREF(PyModule_WarningsModule);
237 PyModule_WarningsModule = NULL;
227 238
228 /* Destroy all modules */ 239 /* Destroy all modules */
229 PyImport_Cleanup(); 240 PyImport_Cleanup();
230 241
231 /* Destroy the database used by _PyImport_{Fixup,Find}Extension */ 242 /* Destroy the database used by _PyImport_{Fixup,Find}Extension */