diff options
| author | Victor Stinner <victor.stinner@haypocalc.com> | 2011-03-20 23:36:35 +0100 |
|---|---|---|
| committer | Victor Stinner <victor.stinner@haypocalc.com> | 2011-03-20 23:36:35 +0100 |
| commit | e0daff1c61e323d2a39dd8241de67082d1f10fd7 (patch) | |
| tree | 4493d32c0b615b49efae69d775bcc8106c6497b1 /Modules | |
| parent | 9c4efe571d73ea85489be34bb75dac923805068a (diff) | |
| download | cpython-git-e0daff1c61e323d2a39dd8241de67082d1f10fd7.tar.gz | |
Issue #11395: io.FileIO().write() clamps the data length to 32,767 bytes on
Windows if the file is a TTY to workaround a Windows bug. The Windows console
returns an error (12: not enough space error) on writing into stdout if
stdout mode is binary and the length is greater than 66,000 bytes (or less,
depending on heap usage).
Diffstat (limited to 'Modules')
| -rw-r--r-- | Modules/_io/fileio.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/Modules/_io/fileio.c b/Modules/_io/fileio.c index f96f2e2ede..1aa5ee992d 100644 --- a/Modules/_io/fileio.c +++ b/Modules/_io/fileio.c @@ -712,7 +712,14 @@ fileio_write(fileio *self, PyObject *args) errno = 0; len = pbuf.len; #if defined(MS_WIN64) || defined(MS_WINDOWS) - if (len > INT_MAX) + if (len > 32767 && isatty(self->fd)) { + /* Issue #11395: the Windows console returns an error (12: not + enough space error) on writing into stdout if stdout mode is + binary and the length is greater than 66,000 bytes (or less, + depending on heap usage). */ + len = 32767; + } + else if (len > INT_MAX) len = INT_MAX; n = write(self->fd, pbuf.buf, (int)len); #else |
