mirror of
https://github.com/python/cpython.git
synced 2025-07-29 14:15:07 +00:00
Issue #12467: warnings: fix a race condition if a warning is emitted at
shutdown, if globals()['__file__'] is None.
This commit is contained in:
parent
13502b19c6
commit
65c153547b
3 changed files with 16 additions and 1 deletions
|
@ -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()))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue