Fix bug 683658 - PyErr_Warn may cause import deadlock.

This commit is contained in:
Mark Hammond 2003-02-19 00:33:33 +00:00
parent 4ccf3e14f0
commit a43fd0c899
3 changed files with 19 additions and 6 deletions

View file

@ -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);