Message217260
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. |
|
Date |
User |
Action |
Args |
2014-04-27 12:56:29 | aronacher | set | recipients:
+ aronacher |
2014-04-27 12:56:29 | aronacher | set | messageid: <1398603389.33.0.793055654008.issue21363@psf.upfronthosting.co.za> |
2014-04-27 12:56:29 | aronacher | link | issue21363 messages |
2014-04-27 12:56:29 | aronacher | create | |
|