Message217260
| 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: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 |
|