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/errors.c | |
parent | 880cca90a5f0897e841699c5a8578a7c56d944d1 (diff) | |
download | cpython-d018c5e104fcf66b4b5cdc680f9ebc12b5ae0c4f.tar.gz |
Fix bug 683658 - PyErr_Warn may cause import deadlock.
Diffstat (limited to 'Python/errors.c')
-rw-r--r-- | Python/errors.c | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/Python/errors.c b/Python/errors.c index e50960661e..d08c1afc12 100644 --- a/Python/errors.c +++ b/Python/errors.c @@ -600,18 +600,17 @@ PyErr_WriteUnraisable(PyObject *obj) Py_XDECREF(tb); } +extern PyObject *PyModule_WarningsModule; /* Function to issue a warning message; may raise an exception. */ int PyErr_Warn(PyObject *category, char *message) { - PyObject *mod, *dict, *func = NULL; + PyObject *dict, *func = NULL; - mod = PyImport_ImportModule("warnings"); - if (mod != NULL) { - dict = PyModule_GetDict(mod); + if (PyModule_WarningsModule != NULL) { + dict = PyModule_GetDict(PyModule_WarningsModule); func = PyDict_GetItemString(dict, "warn"); - Py_DECREF(mod); } if (func == NULL) { PySys_WriteStderr("warning: %s\n", message); |