classification
Title: os.isatty() is not Unix only
Type: behavior Stage: resolved
Components: Documentation, Library (Lib), Tests Versions: Python 3.3, Python 3.4, Python 2.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: docs@python Nosy List: asvetlov, dmi.baranov, docs@python, ezio.melotti, georg.brandl, orsenthil, pitrou, python-dev, techtonik, vstinner
Priority: normal Keywords: easy

Created on 2013-07-25 11:46 by techtonik, last changed 2015-04-06 04:48 by berker.peksag. This issue is now closed.

Messages (17)
msg193694 - (view) Author: anatoly techtonik (techtonik) Date: 2013-07-25 11:46
It seems like os.isatty(0) works on Windows too. Documentation says Unix only:

  http://docs.python.org/2/library/os.html#os.isatty
  http://docs.python.org/3.4/library/os.html#os.isatty


C:\>py -c "import os; print os.isatty(0)"
True

C:\>echo "x" | py -c "import os; print os.isatty(0)"
False

C:\>py -c "import os; print os.isatty(0)" | more
True
msg195479 - (view) Author: Ezio Melotti (ezio.melotti) * (Python committer) Date: 2013-08-17 15:02
Are there tests for this?
msg196718 - (view) Author: anatoly techtonik (techtonik) Date: 2013-09-01 09:45
None that I know of.
msg196725 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2013-09-01 17:48
> Are there tests for this?

Not sure what you mean: there are several tests using isatty() in test suite.

Regardless, there is no #ifdef around the isatty() definition in posixmodule.c, so I can only assume it exists on all platforms.
msg196796 - (view) Author: Dmi Baranov (dmi.baranov) * Date: 2013-09-02 17:50
isatty is a part of of POSIX sub-system at Windows > 5.x (AKA 2000) [1] (file handling equivalents [2]). I think, we need to remove availability note here.

[1] http://msdn.microsoft.com/en-us/library/f4s0ddew.aspx
[2] http://msdn.microsoft.com/en-us/library/kdfaxaay.aspx
msg196822 - (view) Author: Andrew Svetlov (asvetlov) * (Python committer) Date: 2013-09-03 03:53
Agree
msg197175 - (view) Author: Roundup Robot (python-dev) Date: 2013-09-07 18:30
New changeset d5c5ac33b9a1 by Senthil Kumaran in branch '2.7':
os.isatty is not Unix only. Correct the wrong documentation.
http://hg.python.org/cpython/rev/d5c5ac33b9a1
msg197176 - (view) Author: Senthil Kumaran (orsenthil) * (Python committer) Date: 2013-09-07 18:31
I have corrected the documentation. Thanks for raising this issue, anatoly techtonik.
msg197672 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2013-09-13 22:11
Why only changing Python 2 documentation?

http://docs.python.org/dev/library/os.html#os.isatty
still mention "Availability: Unix."
msg197676 - (view) Author: Senthil Kumaran (orsenthil) * (Python committer) Date: 2013-09-13 22:42
I had removed them in all. Something must have gone wrong if still present or I did a mistake.


changeset:   85594:678e3c0d2d99
parent:      85591:c116b658aede
parent:      85593:14ba90816930
user:        Senthil Kumaran <senthil@uthcode.com>
date:        Sat Sep 07 11:30:04 2013 -0700
files:       Doc/library/os.rst
description:
merge from 3.3

Removing the mention of os.isatty mention as Unix only
Correct the wrong documentation.


changeset:   85593:14ba90816930
branch:      3.3
parent:      85589:dd669daad7de
user:        Senthil Kumaran <senthil@uthcode.com>
date:        Sat Sep 07 11:28:58 2013 -0700
files:       Doc/library/os.rst
description:
Removing the mention of os.isatty mention as Unix only
Correct the wrong documentation.


changeset:   85592:d5c5ac33b9a1
branch:      2.7
parent:      85588:523cfc78847c
user:        Senthil Kumaran <senthil@uthcode.com>
msg197967 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2013-09-17 07:58
Senthil: your 3.3->default merge removed the Availability from fpathconf().
msg198041 - (view) Author: Senthil Kumaran (orsenthil) * (Python committer) Date: 2013-09-19 06:10
Georg: Thanks for spotting. I feel bad for the mistake. I shall correct it.
msg198043 - (view) Author: Roundup Robot (python-dev) Date: 2013-09-19 07:10
New changeset 2b7f11ba871c by Senthil Kumaran in branch '3.3':
Correcting the mistake in 14ba90816930
http://hg.python.org/cpython/rev/2b7f11ba871c

New changeset e839e524a7d5 by Senthil Kumaran in branch 'default':
Correcting the mistake in 678e3c0d2d99
http://hg.python.org/cpython/rev/e839e524a7d5
msg198044 - (view) Author: Senthil Kumaran (orsenthil) * (Python committer) Date: 2013-09-19 07:12
Fixed now. Ascertained myself by doing hg diff -r tip^ -U 10 on local commits before pushing. :-)
msg198079 - (view) Author: Dmi Baranov (dmi.baranov) * Date: 2013-09-19 14:47
I found a little difference in isatty implementaions:

Windows
Determines whether a file descriptor is associated with a character device [1]

Unix
Test whether a file descriptor refers to a terminal [2]

So, we having a same behavior for pipes, but different for I/O redirection with pseudo-character devices:

$ ./python -c "import os;print(os.isatty(0))" < /dev/null
False

e:\PCbuild>python_d.exe -c "import os;print(os.isatty(0))" < NUL
True

Other pseudo devices works simular:
e:\PCbuild>python_d.exe -c "import os;print(os.isatty(0))" < CON
True

I having a snippet to fix that, should I open a new issue for patch?


[1] http://msdn.microsoft.com/en-us/library/f4s0ddew.aspx
[2] http://man7.org/linux/man-pages/man3/isatty.3.html
msg198081 - (view) Author: Senthil Kumaran (orsenthil) * (Python committer) Date: 2013-09-19 15:16
Hello Dmi,

> I having a snippet to fix that, should I open a new issue for patch?

Please open a new issue.

Thanks!
msg198271 - (view) Author: anatoly techtonik (techtonik) Date: 2013-09-22 12:12
>
> > I having a snippet to fix that, should I open a new issue for patch?
>
> Please open a new issue.
>

Reference is welcome.
History
Date User Action Args
2015-04-06 04:48:01berker.peksagsetstage: needs patch -> resolved
2013-09-22 12:12:44techtoniksetmessages: + msg198271
2013-09-19 15:16:44orsenthilsetmessages: + msg198081
2013-09-19 14:47:28dmi.baranovsetmessages: + msg198079
2013-09-19 07:12:55orsenthilsetstatus: open -> closed

messages: + msg198044
2013-09-19 07:10:24python-devsetmessages: + msg198043
2013-09-19 06:10:50orsenthilsetmessages: + msg198041
2013-09-17 07:58:42georg.brandlsetstatus: closed -> open
nosy: + georg.brandl
messages: + msg197967

2013-09-13 22:42:03orsenthilsetmessages: + msg197676
2013-09-13 22:11:48vstinnersetnosy: + vstinner
messages: + msg197672
2013-09-07 18:31:21orsenthilsetstatus: open -> closed

nosy: + orsenthil
messages: + msg197176

resolution: fixed
2013-09-07 18:30:15python-devsetnosy: + python-dev
messages: + msg197175
2013-09-03 03:53:40asvetlovsetnosy: + asvetlov
messages: + msg196822
2013-09-02 17:51:00dmi.baranovsetnosy: + dmi.baranov
messages: + msg196796
2013-09-01 17:48:36pitrousetnosy: + pitrou
messages: + msg196725
2013-09-01 09:45:54techtoniksetmessages: + msg196718
2013-08-17 15:02:20ezio.melottisetnosy: + ezio.melotti
messages: + msg195479

components: + Tests
keywords: + easy
2013-07-27 01:19:53terry.reedysetstage: needs patch
type: behavior
versions: - Python 3.1, Python 3.2, Python 3.5
2013-07-25 12:51:46techtoniksetassignee: docs@python

components: + Documentation
nosy: + docs@python
2013-07-25 11:46:19techtonikcreate