Issue #20037: Avoid crashes when doing text I/O late at interpreter shutdown.

This commit is contained in:
Antoine Pitrou 2013-12-21 15:51:54 +01:00
parent 5255b86fba
commit 712cb734bd
9 changed files with 96 additions and 8 deletions

View file

@ -493,8 +493,10 @@ err_closed(void)
static PyObject *
err_mode(char *action)
{
PyErr_Format(IO_STATE->unsupported_operation,
"File not open for %s", action);
_PyIO_State *state = IO_STATE();
if (state != NULL)
PyErr_Format(state->unsupported_operation,
"File not open for %s", action);
return NULL;
}