summaryrefslogtreecommitdiffstats
path: root/Python/errors.c
diff options
context:
space:
mode:
authorMark Hammond <mhammond@skippinet.com.au>2003-07-15 23:03:55 (GMT)
committerMark Hammond <mhammond@skippinet.com.au>2003-07-15 23:03:55 (GMT)
commitedd07737d70f9021d90f3990fd7f527aa9a54e48 (patch)
tree3f1d62b0f65c38d5c14d81ad399918270c1037ca /Python/errors.c
parentd51ce7de97f3aa1cf6ee65975475dce371cd3aea (diff)
downloadcpython-edd07737d70f9021d90f3990fd7f527aa9a54e48.zip
cpython-edd07737d70f9021d90f3990fd7f527aa9a54e48.tar.gz
cpython-edd07737d70f9021d90f3990fd7f527aa9a54e48.tar.bz2
Fix [ 771097 ] frozen programs fail due to implicit import of "warnings".
If the initial import of warnings fails, clear the error. When the module is actually needed, if the original import failed, see if it has managed to find its way to sys.modules yet and if so, remember it.
Diffstat (limited to 'Python/errors.c')
-rw-r--r--Python/errors.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/Python/errors.c b/Python/errors.c
index d43501b..a40844e 100644
--- a/Python/errors.c
+++ b/Python/errors.c
@@ -599,16 +599,17 @@ PyErr_WriteUnraisable(PyObject *obj)
Py_XDECREF(tb);
}
-extern PyObject *PyModule_WarningsModule;
+extern PyObject *PyModule_GetWarningsModule();
/* Function to issue a warning message; may raise an exception. */
int
PyErr_Warn(PyObject *category, char *message)
{
PyObject *dict, *func = NULL;
+ PyObject *warnings_module = PyModule_GetWarningsModule();
- if (PyModule_WarningsModule != NULL) {
- dict = PyModule_GetDict(PyModule_WarningsModule);
+ if (warnings_module != NULL) {
+ dict = PyModule_GetDict(warnings_module);
func = PyDict_GetItemString(dict, "warn");
}
if (func == NULL) {