diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2024-02-05 20:51:11 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-02-05 20:51:11 (GMT) |
commit | 652fbf88c4c422ff17fefd4dcb5e06b5c0e26e74 (patch) | |
tree | 61b36dd4f458619c68bbee592bade7ed18993dda /Lib/_pyio.py | |
parent | 09096a1647913526a3d4fa69a9d2056ec82a8f37 (diff) | |
download | cpython-652fbf88c4c422ff17fefd4dcb5e06b5c0e26e74.zip cpython-652fbf88c4c422ff17fefd4dcb5e06b5c0e26e74.tar.gz cpython-652fbf88c4c422ff17fefd4dcb5e06b5c0e26e74.tar.bz2 |
gh-82626: Emit a warning when bool is used as a file descriptor (GH-111275)
Diffstat (limited to 'Lib/_pyio.py')
-rw-r--r-- | Lib/_pyio.py | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/Lib/_pyio.py b/Lib/_pyio.py index df2c29bf..8a0d0dc 100644 --- a/Lib/_pyio.py +++ b/Lib/_pyio.py @@ -1495,6 +1495,11 @@ class FileIO(RawIOBase): if isinstance(file, float): raise TypeError('integer argument expected, got float') if isinstance(file, int): + if isinstance(file, bool): + import warnings + warnings.warn("bool is used as a file descriptor", + RuntimeWarning, stacklevel=2) + file = int(file) fd = file if fd < 0: raise ValueError('negative file descriptor') |