8000 gh-90102: Optimize io.FileIO.isatty() by serhiy-storchaka · Pull Request #112495 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-90102: Optimize io.FileIO.isatty() #112495

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Fix a race condition.
  • Loading branch information
serhiy-storchaka committed Nov 28, 2023
commit fae5fc5cd40be013733742561942f52a039a1385
4 changes: 3 additions & 1 deletion Modules/_io/fileio.c
Original file line number Diff line number Diff line change
Expand Up @@ -1151,11 +1151,13 @@ _io_FileIO_isatty_impl(fileio *self)
if (self->fd < 0)
return err_closed();
if (self->isatty < 0) {
int res;
Py_BEGIN_ALLOW_THREADS
_Py_BEGIN_SUPPRESS_IPH
self->isatty = isatty(self->fd);
res = isatty(self->fd);
_Py_END_SUPPRESS_IPH
Py_END_ALLOW_THREADS
self->isatty = res;
}
return PyBool_FromLong(self->isatty);
}
Expand Down
0