mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
bpo-38031: Fix a possible assertion failure in _io.FileIO() (GH-GH-5688)
(cherry picked from commit d386115039
)
Co-authored-by: Zackery Spytz <zspytz@gmail.com>
This commit is contained in:
parent
5b7408490f
commit
c06f74f1d6
3 changed files with 15 additions and 1 deletions
|
@ -888,6 +888,14 @@ class IOTest(unittest.TestCase):
|
|||
open('non-existent', 'r', opener=badopener)
|
||||
self.assertEqual(str(cm.exception), 'opener returned -2')
|
||||
|
||||
def test_opener_invalid_fd(self):
|
||||
# Check that OSError is raised with error code EBADF if the
|
||||
# opener returns an invalid file descriptor (see gh-82212).
|
||||
fd = os_helper.make_bad_fd()
|
||||
with self.assertRaises(OSError) as cm:
|
||||
self.open('foo', opener=lambda name, flags: fd)
|
||||
self.assertEqual(cm.exception.errno, errno.EBADF)
|
||||
|
||||
def test_fileio_closefd(self):
|
||||
# Issue #4841
|
||||
with self.open(__file__, 'rb') as f1, \
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue