[issue6929] Confusion between "write" method of rowiobase and rawfileio

Pascal Chambon report at bugs.python.org
Thu Sep 17 11:51:52 CEST 2009


New submission from Pascal Chambon <chambon.pascal at gmail.com>:

It seems the properties of the write methods of these two classes are
mixed up in documentation. I've checked the sources, and actually it
seems the behviour is inverted :
rawiobase streams, which can be pipes or other limited streams, may
write less than len(b) bytes in one operation, and return ; whereas
rawfileio instances, which write on disk, will never fail writing all
the data unless the disk is full (resulting in IOError). It's rawiobase
which does one system call, not rawiofile which will try again until all
is written, isn't it ?

RawIoBase
write(b)
    Write the given bytes or bytearray object, b, to the underlying raw
stream and return the number of bytes written (never less than len(b),
since if the write fails an IOError will be raised).
    A BlockingIOError is raised if the buffer is full, and the
underlying raw stream cannot accept more data at the moment.


RawFileIO :
write(b)
    Write the bytes or bytearray object, b, to the file, and return the
number actually written. Only one system call is made, so it is possible
that only some of the data is written.

----------
assignee: georg.brandl
components: Documentation
messages: 92751
nosy: georg.brandl, pakal
severity: normal
status: open
title: Confusion between "write" method of rowiobase and rawfileio
type: behavior
versions: Python 3.1

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


More information about the Python-bugs-list mailing list