[issue22673] Incorrect fileno for CONOUT$ / stdout

2014-10-19 Thread Aaron Myles Landwehr
New submission from Aaron Myles Landwehr: If I execute the following code, the file descriptor for CONOUT$ has a fileno != 1. With CONIN$ the fileno != 0. Similar code in another language such as perl produces the desired results. sys.stdout.close(); sys.stdout = open(CONOUT$, w);

[issue22673] Incorrect fileno for CONOUT$ / stdout

2014-10-19 Thread R. David Murray
R. David Murray added the comment: This is Windows specific, right? From a quick google is not clear that CONOUT$ *should* point 1, since it supposed to get at the console regardless of whether there has been any redirection. Certainly, relying on it doing so would seem to be problematic.

[issue22673] Incorrect fileno for CONOUT$ / stdout

2014-10-19 Thread eryksun
eryksun added the comment: In Python 2, the closer for sys.stdout is _check_and_flush, which flushes the stream without closing the underlying FILE. https://hg.python.org/cpython/file/ee879c0ffa11/Python/sysmodule.c#l1377 In Python 3, io.FileIO won't close the underlying file descriptor if

[issue22673] Incorrect fileno for CONOUT$ / stdout

2014-10-19 Thread Aaron Myles Landwehr
Aaron Myles Landwehr added the comment: Yeah, it is windows specific. The problem is that if you open conout$ and the descriptor isn't 1, the buffer doesn't flush normally so the console won't display anything unless you manually flush it. Now, why would you want to redirect STDOUT to the

[issue22673] Incorrect fileno for CONOUT$ / stdout

2014-10-19 Thread Aaron Myles Landwehr
Aaron Myles Landwehr added the comment: Note, I just read eryksun's response. That does indeed fix the issues without API changes. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22673 ___

[issue22673] Incorrect fileno for CONOUT$ / stdout

2014-10-19 Thread R. David Murray
R. David Murray added the comment: OK, do we have a documentation issue here with respect to actually closing the standard streams, or do we just close this as not a bug? Now that issue 17401 is closed, in python 3.5 you will at least be able to tell that the standard stream fdclose is set

[issue22673] Incorrect fileno for CONOUT$ / stdout

2014-10-19 Thread Robert Collins
Robert Collins added the comment: I think its worth a note that the stdio streams are constructed specially, even with the repr improvements. -- nosy: +rbcollins ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22673