Mercurial > cpython-lru_cache-weakref
diff 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 |
line wrap: on
line diff
--- a/Python/pythonrun.c Tue Feb 18 23:33:39 2003 +0000 +++ b/Python/pythonrun.c Wed Feb 19 00:33:33 2003 +0000 @@ -60,6 +60,11 @@ true divisions (which they will be in 2.3). */ int _Py_QnewFlag = 0; +/* Reference to 'warnings' module, to avoid importing it + on the fly when the import lock may be held. See 683658 +*/ +PyObject *PyModule_WarningsModule = NULL; + static int initialized = 0; /* API to access the initialized flag -- useful for esoteric use */ @@ -169,6 +174,8 @@ _PyImportHooks_Init(); + PyModule_WarningsModule = PyImport_ImportModule("warnings"); + initsigs(); /* Signal handling stuff, including initintr() */ initmain(); /* Module __main__ */ @@ -225,6 +232,10 @@ /* Cleanup Codec registry */ _PyCodecRegistry_Fini(); + /* drop module references we saved */ + Py_XDECREF(PyModule_WarningsModule); + PyModule_WarningsModule = NULL; + /* Destroy all modules */ PyImport_Cleanup();
