[Python-3000] The future of exceptions
Georg Brandl
g.brandl at gmx.net
Sat Sep 2 18:36:37 CEST 2006
While looking at the changes necessary to implement the exception
related syntax changes (except ... as ..., raise without type),
I came across some more substantial things that I think must be discussed.
* How should exceptions be represented in C code? Should there still
be a (type, value, traceback) triple?
* Could the traceback be made an attribute of the exception?
* What about exception chaining?
Something like this comes to mind::
try:
whatever
except ValueError as err:
raise CustomException("Something went wrong", prev=err)
With tracebacks becoming part of the exception, that could be::
raise CustomException(*args, prev=err, tb=traceback)
(`prev` and `tb` would be keyword-only arguments)
With that, all exception info would be contained in one object,
so sys.exc_info() could be renamed to sys.last_exc().
cheers,
Georg
More information about the Python-3000
mailing list