diff -r f9f9662dfb1f Lib/test/test_subprocess.py --- a/Lib/test/test_subprocess.py Sun Mar 06 01:53:19 2011 +0100 +++ b/Lib/test/test_subprocess.py Sun Mar 06 16:40:28 2011 -0800 @@ -1217,13 +1217,26 @@ subprocess.call([sys.executable, "-c", "import sys; sys.exit(0)"], startupinfo=startupinfo) + def _with_new_console(self, command): + # start a subprocess with CREATE_NEW_CONSOLE and the given command + CREATE_NEW_CONSOLE = 16 + sys.stderr.write(" a DOS box should flash briefly ...\n") + subprocess.check_call(command, creationflags=CREATE_NEW_CONSOLE) + def test_creationflags(self): # creationflags argument - CREATE_NEW_CONSOLE = 16 - sys.stderr.write(" a DOS box should flash briefly ...\n") - subprocess.call(sys.executable + - ' -c "import time; time.sleep(0.25)"', - creationflags=CREATE_NEW_CONSOLE) + self._with_new_console(sys.executable + + ' -c "import time; time.sleep(0.25)"') + + def test_stdout_large(self): + # see: issue #11395 + self._with_new_console([sys.executable, "-c", + "print(b'a' * 66000)"]) + + def test_stdout_binlarge(self): + # see: issue #11395 + self._with_new_console([sys.executable, "-u", "-c", + "print(b'a' * 66000)"]) def test_invalid_args(self): # invalid arguments should raise ValueError diff -r f9f9662dfb1f Modules/_io/fileio.c --- a/Modules/_io/fileio.c Sun Mar 06 01:53:19 2011 +0100 +++ b/Modules/_io/fileio.c Sun Mar 06 16:40:28 2011 -0800 @@ -712,6 +712,12 @@ errno = 0; len = pbuf.len; #if defined(MS_WIN64) || defined(MS_WINDOWS) +#define WIN_CONSOLE_BUFSIZ 32767 + /* Issue #11395: Resolve "IOError: [Errno 12] Not enough space" + when writing into std* in Windows console if the written + length is large enough. */ + if (len > WIN_CONSOLE_BUFSIZ && isatty(self->fd)) + len = WIN_CONSOLE_BUFSIZ; if (len > INT_MAX) len = INT_MAX; n = write(self->fd, pbuf.buf, (int)len);