[Python-Dev] Python in Unicode context

Guido van Rossum guido at python.org
Wed Aug 4 16:34:38 CEST 2004


> > Probably not, but making Exception a new-style class won't be easy.
> 
> What makes you say that?  I've just been remarking on
> comp.lang.python how having Exception be new-style in PyPy --
> indeed, not having old-style classes and all -- has caused
> essentially no problems at all.

I believe that -- it's more that the existing infrastructure that
creates the standard exception hierarchy isn't easily adapted.

I also believe there's a conceptual problem with defining when
something is an acceptable argument to 'raise' -- unless we insist
that exceptions inherit from a designated base class, *every* object
is acceptable, because if it isn't a class, it's an instance of a
class, and raise allows either.  I don't really think that "raise 42"
ought to be acceptable, but I don't know how to prevent it without
requiring a specific base class (excluding a whole slew of specific
base classes seems wrong).

Maybe we can accept old-style classes and instances, strings, and
instances of Exception and its subclasses.  But then we better be sure
that we really want to insist on subclassing from Exception, because
that's rather unpythonic.

> Perhaps I'll work up a patch sometime and see what breaks.

Please do!

--Guido van Rossum (home page: http://www.python.org/~guido/)


More information about the Python-Dev mailing list