[issue7862] fileio.c: ValueError vs. IOError with impossible operations
Stefan Krah
report at bugs.python.org
Fri Feb 5 22:28:20 CET 2010
New submission from Stefan Krah <stefan-usenet at bytereef.org>:
I think that certain FileIO methods should raise IOError instead of
ValueError when a file operation is attempted with the wrong mode.
The methods of IOBase are documented to raise IOError in these situations.
>>> import io
>>> f = io.open("testfile", "w")
>>> f.read()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
IOError: not readable
>>>
>>> f = io.FileIO("testfile", "w")
>>> f.read()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: File not open for reading
----------
components: IO
messages: 98909
nosy: pitrou, skrah, stutzbach
severity: normal
status: open
title: fileio.c: ValueError vs. IOError with impossible operations
type: behavior
versions: Python 2.7, Python 3.1, Python 3.2
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue7862>
_______________________________________
More information about the Python-bugs-list
mailing list