summaryrefslogtreecommitdiffstats
path: root/Modules/_io
diff options
context:
space:
mode:
authorZackery Spytz <zspytz@gmail.com>2022-11-25 12:55:26 (GMT)
committerGitHub <noreply@github.com>2022-11-25 12:55:26 (GMT)
commitd386115039e75c332c8471c239cf7dc5dee791a7 (patch)
tree8a75a98e6bffea8269616d9e16bef7fd0b6277ae /Modules/_io
parentb1dcdefc3abf496a3e37e12b85dd9959f5b70341 (diff)
downloadcpython-d386115039e75c332c8471c239cf7dc5dee791a7.zip
cpython-d386115039e75c332c8471c239cf7dc5dee791a7.tar.gz
cpython-d386115039e75c332c8471c239cf7dc5dee791a7.tar.bz2
bpo-38031: Fix a possible assertion failure in _io.FileIO() (#GH-5688)
Diffstat (limited to 'Modules/_io')
-rw-r--r--Modules/_io/fileio.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/Modules/_io/fileio.c b/Modules/_io/fileio.c
index 0085997..659297e 100644
--- a/Modules/_io/fileio.c
+++ b/Modules/_io/fileio.c
@@ -485,8 +485,12 @@ _io_FileIO___init___impl(fileio *self, PyObject *nameobj, const char *mode,
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