From 8b0508ed4e1ab32422cf2494c7cd345634912b98 Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Mon, 4 Jul 2011 02:43:09 +0200 Subject: Issue #12467: warnings: fix a race condition if a warning is emitted at shutdown, if globals()['__file__'] is None. --- Python/_warnings.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Python/_warnings.c') diff --git a/Python/_warnings.c b/Python/_warnings.c index a797887b9c..07fd683e53 100644 --- a/Python/_warnings.c +++ b/Python/_warnings.c @@ -496,7 +496,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 && PyUnicode_Check(*filename)) { Py_ssize_t len = PyUnicode_GetSize(*filename); Py_UNICODE *unicode = PyUnicode_AS_UNICODE(*filename); -- cgit v1.2.1