Bug on Python2.3.4 [FreeBSD]?

Donn Cave donn at u.washington.edu
Sat Aug 13 01:01:18 CEST 2005


In article <ddiva5$j2m$1 at news2.rz.uni-karlsruhe.de>,
 Uwe Mayer <merkosh at hadiko.de> wrote:

> Friday 12 August 2005 22:12 pm paolino wrote:
> [...]
> >>>>>f = open('test', 'a+')
> >>>>>f.read()
> >> 
> >> ''
> >> 
> >> -> append mode does not read from file, *not ok*
> >> 
> >> 
> > This is right IMO 'a' is appending so seek(-1)
> 
> True, thank you.
> f.tell() shows the file pointer is at EOF. On my Debian Linux (unstable),
> Python 2.3.4 +2.3.5, however, the file pointer is at the beginning of the
> file.
> Is that behaviour intended?

I don't think Python pretends to have any intentions here,
it has to take what it gets from the C library fopen(3)
function.  BSD man pages generally say a+ positions the
stream at end of file (period.)  They claim conformance
with the ISO C90 standard.  I couldn't dig up a (free) copy
of that document, so don't know what it says on this matter.

GNU C man pages say it positions the stream at end for
write and at beginning for read.

   Donn Cave, donn at u.washington.edu



More information about the Python-list mailing list