[issue24658] open().write() fails on 2 GB+ data (OS X)

Ronald Oussoren report at bugs.python.org
Mon Jul 20 14:19:00 CEST 2015


Ronald Oussoren added the comment:

This is likely a platform bug, it fails with os.write as well.  Interestingly enough file.write works fine on Python 2.7 (which uses stdio), that appearently works around this kernel misfeature.

A possible partial workaround is recognise this error in the implementation of os.write and then perform a partial write. Problem is: while write(2) is documented as possibly writing less data than expected most users writing to normal files (as opposed to sockets) probably don’t expect that behavior. On the other hand, os.write already limits writes to INT_MAX on Windows (see _Py_write in Python/fileutils.c)

Because of this I’m in favour of adding a simular workaround on OSX (and can provide a patch).

BTW. the manpage for write says that writev(2) might fail with EINVAL:

     [EINVAL]           The sum of the iov_len values in the iov array over-
                        flows a 32-bit integer.

I wouldn’t be surprised if write(2) is implemented using writev(2) and that this explains the problem.

> On 18 Jul 2015, at 06:05, Serhiy Storchaka <report at bugs.python.org> wrote:
> 
> 
> Changes by Serhiy Storchaka <storchaka at gmail.com>:
> 
> 
> ----------
> components: +Extension Modules, IO -Interpreter Core
> nosy: +haypo, ned.deily, ronaldoussoren
> 
> _______________________________________
> Python tracker <report at bugs.python.org>
> <http://bugs.python.org/issue24658>
> _______________________________________

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue24658>
_______________________________________


More information about the Python-bugs-list mailing list