[Python-3000] exception info [was: Discussions with no PEPs]

Guido van Rossum guido at python.org
Tue Mar 13 18:51:27 CET 2007


He was talking about

  raise ExceptionClass

which I don't want to forbid; it's the

  raise ExceptionClass, args

that will be killed in 3.0. You're correct though that in 2.x, "raise
E" instantiates E immediately. We could change this though, as it
works from C...

--Guido

On 3/13/07, Thomas Wouters <thomas at python.org> wrote:
>
>
> On 3/13/07, Guido van Rossum <guido at python.org> wrote:
> > >
> > > Would this apply to Python code as well? I.e. if you use
> > > a raise statement with a class, it doesn't get instantiated
> > > immediately? And if you catch it with an except clause which
> > > doesn't capture the exception, it's never instantiated?
> > > That would be a bonus.
> >
> > I *think* that's how it works now, and I don't intend to break this.
>
> Eh, I don't see how it can, when you do 'raise ExceptionClass(args)' (like
> you want everyone to use :). It certainly doesn't, now; the arguments to
> 'raise' are just expressions, there is no specialcasing of calling anything.
> I don't believe it does so with the two-argument raise either -- at least,
> when experimenting, the body of an exception class's __init__ method is
> executed before the body of a 'finally' suite.
>
> --
> Thomas Wouters <thomas at python.org>
>
> Hi! I'm a .signature virus! copy me into your .signature file to help me
> spread!


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


More information about the Python-3000 mailing list