[New-bugs-announce] [issue10841] binary stdio

Glenn Linderman report at bugs.python.org
Thu Jan 6 03:11:57 CET 2011

New submission from Glenn Linderman <v+python at g.nevcal.com>:

Per Antoine's request, I wrote this test code, it isn't elegant, I whipped it together quickly; but it shows the issue.  The issue may be one of my ignorance, but it does show the behavior I described in issue 4953. Here's the output from the various test parameters that might be useful in running the test.

>c:\python32\python.exe test.py test 1
['c:\\python32\\python.exe', 'test.py', '1']
All OK

>c:\python32\python.exe test.py test 2
['c:\\python32\\python.exe', 'test.py', '2']
Not OK: b'abc\r\r\ndef\r\r\n'

>c:\python32\python.exe test.py test 3
['c:\\python32\\python.exe', 'test.py', '3']
All OK

>c:\python32\python.exe test.py test 4
['c:\\python32\\python.exe', 'test.py', '4']
Not OK: b'abc\r\r\ndef\r\r\n'

>c:\python32\python.exe test.py test 1-u
['c:\\python32\\python.exe', '-u', 'test.py', '1-u']
All OK

>c:\python32\python.exe test.py test 2-u
['c:\\python32\\python.exe', '-u', 'test.py', '2-u']
All OK

>c:\python32\python.exe test.py test 3-u
['c:\\python32\\python.exe', '-u', 'test.py', '3-u']
All OK

>c:\python32\python.exe test.py test 4-u
['c:\\python32\\python.exe', '-u', 'test.py', '4-u']
All OK


Note that test 2 and 4, which do not use the mscvrt stuff, have double \r: one sent by the code, and another added, apparently by MSC newline processing.  test 2-u and 4-u, which are invoking the subprocess with Python's -u parameter, also do not exhibit the problem, even though the mscvrt stuff is not used.  This seems to indicate that Python's -u parameter does approximately the same thing as my windows_binary function.

Seems like if Python already has code for this, that it would be nice to either make it more easily available to the user as an API (like my windows_binary function, invoked with a single line) in the io or sys modules (since it is used to affect sys.std* files).

And it would be nice if the function "worked cross-platform", even if it is a noop on most platforms.

files: test.py
messages: 125500
nosy: v+python
priority: normal
severity: normal
status: open
title: binary stdio
Added file: http://bugs.python.org/file20285/test.py

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list