[Python-3000] Exception tracebacks and PEP 3101
Talin
talin at acm.org
Tue Mar 6 07:21:40 CET 2007
Patrick Maupin wrote:
> 1) What is the best thing to do right now for PEP3101?
>
> 2) If the "right now" answer isn't very good, is this really a more
> general problem that needs work? As more "little languages" do things
> like manipulate the AST, it might become very useful to have the
> ability to place almost arbitrary objects on the traceback stack.
Off the top of my head (without thinking about it too deeply) the way I
would approach it is to catch the exception inside the string formatting
function, wrap it in another exception that has additional information
about where in the formatting string the error occurred, and then
re-raise that second exception, using the traceback provided from the
first exception.
So for example, at the application level, you might get an exception
with a message such as: "Error in format string, line 2, character 7:
Argument Exception"
-- Talin
More information about the Python-3000
mailing list