diff options
author | Mark Hammond <mhammond@skippinet.com.au> | 2003-02-19 00:33:33 +0000 |
---|---|---|
committer | Mark Hammond <mhammond@skippinet.com.au> | 2003-02-19 00:33:33 +0000 |
commit | d018c5e104fcf66b4b5cdc680f9ebc12b5ae0c4f (patch) | |
tree | 74dcc0fc2b642cbba8978268c3d95923680ed9a8 /Python/pythonrun.c | |
parent | 880cca90a5f0897e841699c5a8578a7c56d944d1 (diff) | |
download | cpython-d018c5e104fcf66b4b5cdc680f9ebc12b5ae0c4f.tar.gz |
Fix bug 683658 - PyErr_Warn may cause import deadlock.
Diffstat (limited to 'Python/pythonrun.c')
-rw-r--r-- | Python/pythonrun.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/Python/pythonrun.c b/Python/pythonrun.c index 1faab509ba..2845d24295 100644 --- a/Python/pythonrun.c +++ b/Python/pythonrun.c @@ -60,6 +60,11 @@ int Py_IgnoreEnvironmentFlag; /* e.g. PYTHONPATH, PYTHONHOME */ 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 @@ Py_Initialize(void) _PyImportHooks_Init(); + PyModule_WarningsModule = PyImport_ImportModule("warnings"); + initsigs(); /* Signal handling stuff, including initintr() */ initmain(); /* Module __main__ */ @@ -225,6 +232,10 @@ Py_Finalize(void) /* Cleanup Codec registry */ _PyCodecRegistry_Fini(); + /* drop module references we saved */ + Py_XDECREF(PyModule_WarningsModule); + PyModule_WarningsModule = NULL; + /* Destroy all modules */ PyImport_Cleanup(); |