Author: Armin Rigo <[email protected]>
Branch:
Changeset: r92167:eaa386e4970b
Date: 2017-08-18 17:22 +0200
http://bitbucket.org/pypy/pypy/changeset/eaa386e4970b/
Log: Issue #2636
Add the same workaround as CPython for os.write() on Windows on a
tty
diff --git a/rpython/rlib/rposix.py b/rpython/rlib/rposix.py
--- a/rpython/rlib/rposix.py
+++ b/rpython/rlib/rposix.py
@@ -205,6 +205,18 @@
if not is_valid_fd(fd):
from errno import EBADF
raise OSError(EBADF, 'Bad file descriptor')
+
+ def _bound_for_write(fd, count):
+ if count > 32767 and c_isatty(fd):
+ # CPython Issue #11395, PyPy Issue #2636: 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). Can't easily
+ # test that, because we need 'fd' to be non-redirected...
+ count = 32767
+ elif count > 0x7fffffff:
+ count = 0x7fffffff
+ return count
else:
def is_valid_fd(fd):
return 1
@@ -213,6 +225,9 @@
def validate_fd(fd):
pass
+ def _bound_for_write(fd, count):
+ return count
+
def closerange(fd_low, fd_high):
# this behaves like os.closerange() from Python 2.6.
for fd in xrange(fd_low, fd_high):
@@ -449,6 +464,7 @@
def write(fd, data):
count = len(data)
validate_fd(fd)
+ count = _bound_for_write(fd, count)
with rffi.scoped_nonmovingbuffer(data) as buf:
return handle_posix_error('write', c_write(fd, buf, count))
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit