Issue 6082: os.path.sameopenfile reports that standard streams are the same (original) (raw)
Issue6082
Created on 2009-05-22 00:56 by ryles, last changed 2022-04-11 14:56 by admin. This issue is now closed.
| Messages (3) | ||
|---|---|---|
| msg88174 - (view) | Author: Ryan Leslie (ryles) | Date: 2009-05-22 00:56 |
| Python 2.6.1 (r261:67515, Apr 2 2009, 18:25:55) [GCC 4.1.2 20071124 (Red Hat 4.1.2-42)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import sys, os >>> os.path.sameopenfile(sys.stdin.fileno(), sys.stdout.fileno()) True >>> os.path.sameopenfile(sys.stdout.fileno(), sys.stderr.fileno()) True >>> null = open(os.devnull) >>> os.path.sameopenfile(sys.stdin.fileno(), null.fileno()) False >>> # That worked. | ||
| msg88175 - (view) | Author: Philip Jenvey (pjenvey) * ![]() |
Date: 2009-05-22 01:45 |
| They are the same file, namely your tty Python 2.6 (r26:66714, Oct 8 2008, 22:16:30) [GCC 4.0.1 (Apple Inc. build 5465)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> import os, sys >>> [os.ttyname(fp.fileno()) for fp in sys.stdin, sys.stdout, sys.stderr] ['/dev/ttys002', '/dev/ttys002', '/dev/ttys002'] | ||
| msg88178 - (view) | Author: Ryan Leslie (ryles) | Date: 2009-05-22 03:34 |
| Thanks for the quick response, Philip. Makes even more sense now that I see: Python 2.6.1 (r261:67515, Apr 2 2009, 18:25:55) [GCC 4.1.2 20071124 (Red Hat 4.1.2-42)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> open('/dev/stdout').readline() hello 'hello\n' >>> open('/dev/stdin').readline() hello 'hello\n' >>> |
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022-04-11 14:56:49 | admin | set | github: 50332 |
| 2009-05-22 03:35:31 | ryles | set | status: open -> closed |
| 2009-05-22 03:35:01 | ryles | set | status: closed -> openmessages: + |
| 2009-05-22 01:58:45 | r.david.murray | set | status: open -> closedresolution: not a bugstage: resolved |
| 2009-05-22 01:45:52 | pjenvey | set | nosy: + pjenveymessages: + |
| 2009-05-22 00:56:46 | ryles | create |
