diff options
author | Antoine Pitrou <solipsis@pitrou.net> | 2013-12-21 14:51:54 (GMT) |
---|---|---|
committer | Antoine Pitrou <solipsis@pitrou.net> | 2013-12-21 14:51:54 (GMT) |
commit | 712cb734bda0227861630b365a97dfec88798c3b (patch) | |
tree | f0e79f0b144395b5a02d32de09dca263e669ee53 /Modules/_io/fileio.c | |
parent | 5255b86fba38a5e22a0991772a3c1bbf3edd66cc (diff) | |
download | cpython-712cb734bda0227861630b365a97dfec88798c3b.zip cpython-712cb734bda0227861630b365a97dfec88798c3b.tar.gz cpython-712cb734bda0227861630b365a97dfec88798c3b.tar.bz2 |
Issue #20037: Avoid crashes when doing text I/O late at interpreter shutdown.
Diffstat (limited to 'Modules/_io/fileio.c')
-rw-r--r-- | Modules/_io/fileio.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/Modules/_io/fileio.c b/Modules/_io/fileio.c index 0e1e709..cbb2daf 100644 --- a/Modules/_io/fileio.c +++ b/Modules/_io/fileio.c @@ -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; } |