mirror of
https://github.com/python/cpython.git
synced 2025-08-22 09:45:06 +00:00
Fix bug 683658 - PyErr_Warn may cause import deadlock.
This commit is contained in:
parent
4ccf3e14f0
commit
a43fd0c899
3 changed files with 19 additions and 6 deletions
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue