diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2022-11-25 13:18:41 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-11-25 13:18:41 (GMT) |
commit | c42681546a06241f901cb4029905ae070100d36d (patch) | |
tree | 2b338049500e604bf5891c5114a519e8449a8ce3 /Modules | |
parent | 59241fe2a223a1202728169984a8793a88e4abb7 (diff) | |
download | cpython-c42681546a06241f901cb4029905ae070100d36d.zip cpython-c42681546a06241f901cb4029905ae070100d36d.tar.gz cpython-c42681546a06241f901cb4029905ae070100d36d.tar.bz2 |
bpo-38031: Fix a possible assertion failure in _io.FileIO() (GH-GH-5688)
(cherry picked from commit d386115039e75c332c8471c239cf7dc5dee791a7)
Co-authored-by: Zackery Spytz <zspytz@gmail.com>
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/_io/fileio.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/Modules/_io/fileio.c b/Modules/_io/fileio.c index b9856b3..bf34b7c 100644 --- a/Modules/_io/fileio.c +++ b/Modules/_io/fileio.c @@ -494,8 +494,12 @@ _Py_COMP_DIAG_POP ret = -1; if (!fd_is_own) self->fd = -1; - if (self->fd >= 0) + if (self->fd >= 0) { + PyObject *exc, *val, *tb; + PyErr_Fetch(&exc, &val, &tb); internal_close(self); + _PyErr_ChainExceptions(exc, val, tb); + } done: #ifdef MS_WINDOWS |