diff Python/errors.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 cc05c2c8660e
children 5fbdcaef9dda
line wrap: on
line diff
--- a/Python/errors.c	Tue Feb 18 23:33:39 2003 +0000
+++ b/Python/errors.c	Wed Feb 19 00:33:33 2003 +0000
@@ -600,18 +600,17 @@
 	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);