Message184003
the docs (http://docs.python.org/3.x/library/io.html#io.FileIO) do not document closefd, and AFAICT it isn't possible to tell if closefd is set after the object is created. Specifically it does not show up in the repr().
>>> import sys
>>> sys.stdout
<_io.TextIOWrapper name='<stdout>' mode='w' encoding='UTF-8'>
>>> sys.stdout.buffer
<_io.BufferedWriter name='<stdout>'>
>>> sys.stdout.buffer.raw
<_io.FileIO name='<stdout>' mode='wb'>
If one wants to reopen sys.std in non-buffered mode, the right thing to do according to a recent thread on python-ideas is to use fdopen - e.g.
mystream = io.open(sys.stdout.fileno(), 'wt', 0)
but this will set closefd to True in the new object, which results in hilarity when it gets garbage collected. And you cannot tell or compare that to the original stdout because of the lack of exposure of this attribute and it's implications. (Does it close the fd on __del__? After each operation? On close() being called on the FileIO object?) |
|
Date |
User |
Action |
Args |
2013-03-12 03:12:07 | rbcollins | set | recipients:
+ rbcollins |
2013-03-12 03:12:07 | rbcollins | set | messageid: <1363057927.36.0.00381165430664.issue17401@psf.upfronthosting.co.za> |
2013-03-12 03:12:07 | rbcollins | link | issue17401 messages |
2013-03-12 03:12:05 | rbcollins | create | |
|