[Python-3000] Pre-peps on raise and except changes

Nick Coghlan ncoghlan at gmail.com
Sat Feb 10 09:08:09 CET 2007


Collin Winter wrote:
> I think so. I've already got language ready for the section on using
> BaseException.with_traceback() in the 2->3 raise translations, and
> I'll work up additional language for the transition plan sometime this
> weekend.

If with_traceback() is an instance method, does it mutate the existing 
exception or create a new one?

To avoid any confusion, perhaps it should instead be a class method 
equivalent to the following:

   @classmethod
   def with_traceback(*args, **kwds):
      cls = args[0]
      tb = args[1]
      args = args[2:]
      exc = cls(*args, **kwds)
      exc.__traceback__ = tb
      return exc

Usage would look like:

   raise E.with_traceback(T, V)


Cheers,
Nick.

-- 
Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia
---------------------------------------------------------------
             http://www.boredomandlaziness.org


More information about the Python-3000 mailing list