Bug on Python2.3.4 [FreeBSD]?
Uwe Mayer
merkosh at hadiko.de
Fri Aug 12 14:04:51 EDT 2005
<posted & mailed>
Hi,
AFAICT there seems to be a bug on FreeBSD's Python 2.3.4 open function. The
documentation states:
> Modes 'r+', 'w+' and 'a+' open the file for updating (note that 'w+'
> truncates the file). Append 'b' to the mode to open the file in binary
> mode, on systems that differentiate between binary and text files (else it
> is ignored). If the file cannot be opened, IOError is raised.
Consider:
$ cat test
lalala
$ python2.3
Python 2.3.4 (#2, Jan 4 2005, 04:42:43)
[GCC 2.95.4 20020320 [FreeBSD]] on freebsd4
Type "help", "copyright", "credits" or "license" for more information.
>>> f = open('test', 'r+')
>>> f.read()
'lalala\n'
>>> f.write('testing')
>>> f.close()
>>>
[1]+ Stopped python2.3
$ cat test
lalala
-> write did not work; ok
$ fg
python2.3
>>> f = open('test', 'a+')
>>> f.read()
''
-> append mode does not read from file, *not ok*
>>> f = open('test', 'w+')
>>> f.read()
''
>>>
$ cat test
-> w+ truncated file, ok
Can anyone confirm that? Is there any other way of opening a file for
appending instead of a+?
Thanks,
Ciao
Uwe
More information about the Python-list
mailing list