Issue 7862: fileio.c: ValueError vs. IOError with impossible operations (original) (raw)
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 "", line 1, in IOError: not readable
f = io.FileIO("testfile", "w") f.read() Traceback (most recent call last): File "", line 1, in ValueError: File not open for reading