Issue #12467: warnings: fix a race condition if a warning is emitted at

shutdown, if globals()['__file__'] is None.
This commit is contained in:
Victor Stinner 2011-07-04 03:05:37 +02:00
parent 13502b19c6
commit 65c153547b
3 changed files with 16 additions and 1 deletions

View file

@ -491,7 +491,7 @@ setup_context(Py_ssize_t stack_level, PyObject **filename, int *lineno,
/* Setup filename. */
*filename = PyDict_GetItemString(globals, "__file__");
if (*filename != NULL) {
if (*filename != NULL && PyString_Check(*filename)) {
Py_ssize_t len = PyString_Size(*filename);
const char *file_str = PyString_AsString(*filename);
if (file_str == NULL || (len < 0 && PyErr_Occurred()))