Author eryksun
Recipients eryksun, r.david.murray, snaphat, steve.dower, tim.golden, zach.ware
Date 2014-10-19.21:59:54
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1413755994.29.0.527757131654.issue22673@psf.upfronthosting.co.za>
In-reply-to
Content
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 closefd is False.

    >>> sys.stdout.buffer.raw.closefd
    False

It isn't a writable attribute. It gets initialized to False by create_stdio (line 1034).

https://hg.python.org/cpython/file/ab2c023a9432/Python/pythonrun.c#l1006

You'll can call os.close.

Python 2:

    >>> sys.stdout.close(); os.close(1); sys.stdout = open('CONOUT$', 'w', buffering=0)
    >>> sys.stdout.fileno()
    1

Python 3:

    >>> sys.stdout.close(); os.close(1); sys.stdout = open('CONOUT$', 'w') 
    >>> sys.stdout.fileno()
    1
History
Date User Action Args
2014-10-19 21:59:54eryksunsetrecipients: + eryksun, tim.golden, r.david.murray, zach.ware, steve.dower, snaphat
2014-10-19 21:59:54eryksunsetmessageid: <1413755994.29.0.527757131654.issue22673@psf.upfronthosting.co.za>
2014-10-19 21:59:54eryksunlinkissue22673 messages
2014-10-19 21:59:54eryksuncreate