diff options
author | Guido van Rossum <guido@python.org> | 2007-10-29 17:39:59 +0000 |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 2007-10-29 17:39:59 +0000 |
commit | 196f43d7df70810fd9d3967fc236a5211faea438 (patch) | |
tree | 17d8b37e5163065dd4bee54c622cb00b2f69a52f /Lib/fileinput.py | |
parent | 28a88e92b4b8311ddbe380119feee47168412b23 (diff) | |
download | cpython-196f43d7df70810fd9d3967fc236a5211faea438.tar.gz |
Patch 1341 by Amaury Forgeot d'Arc.
This patch corrects test_fileinput on Windows: when redirecting stdout,
os.open should be given O_BINARY, because the file descriptor is then
wrapped in a text-mode file; os.fdopen(fd, "w").
Diffstat (limited to 'Lib/fileinput.py')
-rw-r--r-- | Lib/fileinput.py | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/Lib/fileinput.py b/Lib/fileinput.py index 0d7ffada8c..e4c71ced6d 100644 --- a/Lib/fileinput.py +++ b/Lib/fileinput.py @@ -326,9 +326,11 @@ class FileInput: except OSError: self._output = open(self._filename, "w") else: - fd = os.open(self._filename, - os.O_CREAT | os.O_WRONLY | os.O_TRUNC, - perm) + mode = os.O_CREAT | os.O_WRONLY | os.O_TRUNC + if hasattr(os, 'O_BINARY'): + mode |= os.O_BINARY + + fd = os.open(self._filename, mode, perm) self._output = os.fdopen(fd, "w") try: if hasattr(os, 'chmod'): |