<br><br><div><span class="gmail_quote">On 9/2/06, <b class="gmail_sendername">Georg Brandl</b> <<a href="mailto:g.brandl@gmx.net">g.brandl@gmx.net</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
While looking at the changes necessary to implement the exception<br>related syntax changes (except ... as ..., raise without type),<br>I came across some more substantial things that I think must be discussed.</blockquote>
<div><br>You have read Ping's PEP 344, right? </div><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">* How should exceptions be represented in C code? Should there still
<br> be a (type, value, traceback) triple?<br><br>* Could the traceback be made an attribute of the exception?</blockquote><div><br>The problem with this is that it keeps the frame alive. This is why this and exception chaining were considered a design issue in Ping's PEP since that is a lot of stuff to keep alive.
<br></div><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">* What about exception chaining?<br><br>Something like this comes to mind::<br>
<br> try:<br> whatever<br> except ValueError as err:<br> raise CustomException("Something went wrong", prev=err)<br><br>With tracebacks becoming part of the exception, that could be::<br><br>
raise CustomException(*args, prev=err, tb=traceback)<br><br>(`prev` and `tb` would be keyword-only arguments)<br><br>With that, all exception info would be contained in one object,<br>so sys.exc_info() could be renamed to
sys.last_exc().</blockquote><div><br>Right, which is why the original suggestion came up in the first place. It would be nice to compartmentalize exceptions entirely, but the worry of keeping a ont of memory alive for it needs to be addressed, especially if exceptions are to be kept lightweight and usable for things other than flagging errors.
<br><br>-Brett<br></div><br></div>