mirror of
https://github.com/python/cpython.git
synced 2025-08-22 17:55:18 +00:00
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.
This commit is contained in:
parent
d51ce7de97
commit
edd07737d7
2 changed files with 40 additions and 8 deletions
|
@ -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) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue