[3.13] gh-71253: Match _io exception in _pyio (gh-133985) (gh-134431)

Test was only testing _io, expanded to cover _pyio.

(cherry picked from commit 06eaf4055c)

Co-authored-by: Cody Maloney <cmaloney@users.noreply.github.com>
Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
This commit is contained in:
Miss Islington (bot) 2025-05-21 17:14:00 +02:00 committed by GitHub
parent de6d199c1d
commit 046125e5b6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 7 additions and 3 deletions

View file

@ -1559,7 +1559,8 @@ class FileIO(RawIOBase):
if not isinstance(fd, int):
raise TypeError('expected integer from opener')
if fd < 0:
raise OSError('Negative file descriptor')
# bpo-27066: Raise a ValueError for bad value.
raise ValueError(f'opener returned {fd}')
owned_fd = fd
if not noinherit_flag:
os.set_inheritable(fd, False)