[Python-Dev] thoughts on having EOFError inherit from EnvironmentError?
Guido van Rossum
guido at python.org
Tue Apr 15 04:11:26 CEST 2008
On Mon, Apr 14, 2008 at 6:59 PM, Greg Ewing <greg.ewing at canterbury.ac.nz> wrote:
> Guido van Rossum wrote:
> > I don't think of EOFError as an environmental error... This is quite
> > a different level of error than what EnvironmentError typically means
> I think it depends. Any "expected" EOFErrors are going to be
> caught by the surrounding code before propagating very far.
> An *uncaught* EOFError probably means that a file was shorter
> than you expected it to be, which counts as an environmental
> error to my way of thinking.
No, that's some kind of parsing error. EnvironmentError doesn't
concern itself with the contents of files.
> My current coding style involves wrapping an "except EnvironmentError"
> around any major operation and reporting it as a "File could not be
> read/written/whatever because..." kind of message. Having
> EOFError get missed by that would be a nuisance.
But what operations raise EOFError? Surely you're not using
raw_input()? It's really only there for teaching.
--Guido van Rossum (home page: http://www.python.org/~guido/)
More information about the Python-Dev