]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-90102: Fix pyio _isatty_open_only() (#125089)
authorCody Maloney <cmaloney@users.noreply.github.com>
Tue, 8 Oct 2024 11:49:50 +0000 (04:49 -0700)
committerGitHub <noreply@github.com>
Tue, 8 Oct 2024 11:49:50 +0000 (11:49 +0000)
Spotted by @ngnpope.

`isatty` returns False to indicate the file is not a TTY. The C
implementation of _io does that (`Py_RETURN_FALSE`) but I got the
bool backwards in the _pyio implementaiton.

Lib/_pyio.py

index 2a1d2a33d02960809ea8cfe95e9d07be74be6d4b..7b6d10c008d3cb320e2a5e4c643b62be06e99ca7 100644 (file)
@@ -1806,7 +1806,7 @@ class FileIO(RawIOBase):
         """
         if (self._stat_atopen is not None
             and not stat.S_ISCHR(self._stat_atopen.st_mode)):
-            return True
+            return False
         return os.isatty(self._fd)
 
     @property