[Python-Dev] thoughts on having EOFError inherit from EnvironmentError? (original) (raw)

Greg Ewing greg.ewing at canterbury.ac.nz
Sat Apr 19 02🔞47 CEST 2008


Antoine Pitrou wrote:

Why do you want to derive program bugs from EnvironmentError ? Usually I derive them from ValueError, RuntimeError or simply Exception.

I'm not talking about program bugs, I'm talking about exceptions due to something the user did wrong.

I like to be able to do this:

try: f = open(somefile) mungulate(f) f.close() except EnvironmentError, e: big_nasty_alert("Couldn't mungulate: %s" % e)

I don't want this to catch things like TypeError and ValueError that indicate a program bug if they ever escape. I want those to propagate and cause a traceback or get handled at a higher level.

By deriving my own external-factors exceptions from EnvironmentError, this all works very nicely.

From its position in the exception hierarchy, this seems to be just the sort of thing that EnvironmentError is designed for, and I'm perplexed to be told that it's not.

-- Greg



More information about the Python-Dev mailing list