Mercurial > cpython-lru_cache-weakref
comparison 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 |
comparison
equal
deleted
inserted
replaced
| 27957:91fc9637e56a | 27958:e07b21ea3c45 |
|---|---|
| 598 Py_XDECREF(t); | 598 Py_XDECREF(t); |
| 599 Py_XDECREF(v); | 599 Py_XDECREF(v); |
| 600 Py_XDECREF(tb); | 600 Py_XDECREF(tb); |
| 601 } | 601 } |
| 602 | 602 |
| 603 extern PyObject *PyModule_WarningsModule; | |
| 603 | 604 |
| 604 /* Function to issue a warning message; may raise an exception. */ | 605 /* Function to issue a warning message; may raise an exception. */ |
| 605 int | 606 int |
| 606 PyErr_Warn(PyObject *category, char *message) | 607 PyErr_Warn(PyObject *category, char *message) |
| 607 { | 608 { |
| 608 PyObject *mod, *dict, *func = NULL; | 609 PyObject *dict, *func = NULL; |
| 609 | 610 |
| 610 mod = PyImport_ImportModule("warnings"); | 611 if (PyModule_WarningsModule != NULL) { |
| 611 if (mod != NULL) { | 612 dict = PyModule_GetDict(PyModule_WarningsModule); |
| 612 dict = PyModule_GetDict(mod); | |
| 613 func = PyDict_GetItemString(dict, "warn"); | 613 func = PyDict_GetItemString(dict, "warn"); |
| 614 Py_DECREF(mod); | |
| 615 } | 614 } |
| 616 if (func == NULL) { | 615 if (func == NULL) { |
| 617 PySys_WriteStderr("warning: %s\n", message); | 616 PySys_WriteStderr("warning: %s\n", message); |
| 618 return 0; | 617 return 0; |
| 619 } | 618 } |
