This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author aronacher
Recipients aronacher
Date 2014-04-27.12:56:29
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1398603389.33.0.793055654008.issue21363@psf.upfronthosting.co.za>
In-reply-to
Content
I'm trying to write some code that fixes a misconfigured sys.stdin on a case by case bases but unfortunately I cannot use TextIOWrapper for this because it always closes the underlying file:


Python

>>> import io
>>> sys.stdin.encoding
'ANSI_X3.4-1968'
>>> stdin = sys.stdin
>>> correct_stdin = io.TextIOWrapper(stdin.buffer, 'utf-8')
>>> correct_stdin.readline()
foobar
'foobar\n'
>>> del correct_stdin
>>> stdin.readline()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: I/O operation on closed file.

Ideally there would be a way to disable this behavior.
History
Date User Action Args
2014-04-27 12:56:29aronachersetrecipients: + aronacher
2014-04-27 12:56:29aronachersetmessageid: <1398603389.33.0.793055654008.issue21363@psf.upfronthosting.co.za>
2014-04-27 12:56:29aronacherlinkissue21363 messages
2014-04-27 12:56:29aronachercreate