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.

classification
Title: Need real TextIOWrapper for stdin/stdout
Type: behavior Stage:
Components: IO Versions: Python 3.2, Python 3.3
process
Status: closed Resolution: duplicate
Dependencies: Superseder:
Assigned To: Nosy List: amaury.forgeotdarc, pitrou, r.david.murray, r_mosaic, terry.reedy, vstinner
Priority: normal Keywords:

Created on 2011-06-15 04:59 by r_mosaic, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Messages (8)
msg138356 - (view) Author: Fan Decheng (r_mosaic) Date: 2011-06-15 04:59
Since "-u" is made default and binary stdio implemented in 3.2, many of my scripts cannot run directly in Python 3.2, because they expect "\n" from stdin, but on Windows "\r\n" is got.

Since that binary stdio being default is necessary for features like CGI, what I am expecting is to get a real TextIOWrapper for stdin, so that I can still use my old code. Besides, type(sys.stdio) should no longer say TextIOWrapper, because TextIOWrapper implies the conversion from "\r\n" to "\n".

Steps to reproduce:
In Python 3.2:
>>> import sys
>>> type(sys.stdin)
<class '_io.TextIOWrapper'>
>>> sys.stdin.readline()
a
'a\r\n'
>>> type(sys.stdout)
<class '_io.TextIOWrapper'>

Expected result:
There should be some form of text support, such as textstream(sys.stdin).readline(). Also type(sys.stdin) should not say something like "TextIOWrapper". Same for sys.stdout.
msg138360 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2011-06-15 10:11
I can't reproduce. Victor?


Z:\default>PCbuild\amd64\python_d.exe
Python 3.3a0 (default, Jun  8 2011, 17:49:13) [MSC v.1500 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.stdin.readline()
a
'a\n'
>>> ^Z

Z:\default>PCbuild\amd64\python_d.exe -u
Python 3.3a0 (default, Jun  8 2011, 17:49:13) [MSC v.1500 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.stdin.readline()
a
'a\n'
msg138361 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2011-06-15 11:55
I think that this issue is a duplicate of the issue #11272: Python 3.2.1 has been released recently and contains the fix. Can you try this version Fan?
msg138362 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2011-06-15 11:56
Note: Python 3.2 has another regression related to the Windows console (issue #11395), bug fixed in 3.2.1.
msg138560 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2011-06-17 23:18
WinXP, 3.2.0
>>> type(sys.stdin)
<class 'idlelib.rpc.RPCProxy'>
>>> sys.stdin.readline()
a
'a\n'
msg138562 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2011-06-17 23:45
I'm not sure what the point of your example is, Terry.  Is it not fixed in 3.2.1?
msg138567 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2011-06-18 04:44
That, like Antoine, I also could not reproduce, even in 3.2.0, when running under IDLE. However, with regular command line Python:
Python 3.2 (r32:88445, Feb 20 2011, 21:29:02) [MSC v.1500 32 bit (Intel)]
>>> import sys
>>> sys.stdin.readline()
a
'a\r\n'
so there really was a bug. If fixed in 3.2.1, this issue could be closed.
msg138701 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2011-06-20 12:10
> so there really was a bug.
> If fixed in 3.2.1, this issue could be closed.

This issue is a duplicate of #11272: upgrade to Python 3.2.1.
History
Date User Action Args
2022-04-11 14:57:18adminsetgithub: 56546
2011-06-20 12:10:06vstinnersetstatus: open -> closed
resolution: duplicate
messages: + msg138701
2011-06-18 04:44:16terry.reedysetmessages: + msg138567
2011-06-17 23:46:00r.david.murraysetnosy: + r.david.murray
messages: + msg138562
2011-06-17 23:18:30terry.reedysetnosy: + terry.reedy
messages: + msg138560
2011-06-15 11:56:36vstinnersetmessages: + msg138362
2011-06-15 11:55:54vstinnersetmessages: + msg138361
2011-06-15 10:11:12pitrousetnosy: + amaury.forgeotdarc, vstinner, pitrou

messages: + msg138360
versions: + Python 3.3
2011-06-15 04:59:52r_mosaiccreate