Three patches from issue #1047, by Amaury Forgeot d'Arc:

1/ getargs.diff adds the 'Z' and 'Z#' format specifiers for
PyArg_ParseTuple. They mimic z and z# for unicode strings, by accepting
a Unicode or None (in which case the Py_UNICODE* pointer is set to
NULL). With doc and tests.

2/ subprocess.diff converts file PC/_subprocess.c to unicode. We use the
Unicode version of the win32 api (and Z conversion from previous patch)

3/ stdout.diff: sys.stdout must not convert the line endings, Windows
already does it.
Without this patch, when redirecting the output of python, the file
contains \r\r\n for each line. (test_subprocess did catch this)

However, I (GvR) removed the change to _fileio.c (included in the
patches) that prevents closing file descripors < 3 from being closed;
I think that needs to be solved in a different way.
This commit is contained in:
Guido van Rossum 2007-08-29 18:38:11 +00:00
parent e86254e256
commit fb67be2f6b
5 changed files with 118 additions and 32 deletions

View file

@ -414,9 +414,9 @@ def installnewio():
def __new__(cls, *args, **kwds):
return io.open(*args, **kwds)
__builtin__.open = open
sys.__stdin__ = sys.stdin = io.open(0, "r")
sys.__stdout__ = sys.stdout = io.open(1, "w")
sys.__stderr__ = sys.stderr = io.open(2, "w")
sys.__stdin__ = sys.stdin = io.open(0, "r", newline='\n')
sys.__stdout__ = sys.stdout = io.open(1, "w", newline='\n')
sys.__stderr__ = sys.stderr = io.open(2, "w", newline='\n')
def main():