[adding back the list] On 3/13/07, Josiah Carlson <[EMAIL PROTECTED]> wrote: > What if the thing to the right of 'as' were assigned different values > depending on what it was? If it were one name, it would be the > exception (without traceback) "except ... as foo". If it was a 3-tuple > of names, it would get all three: "except ... as ecls, e, tb:". (with 2, > maybe e and tb) Anything else could raise a SyntaxError during the code > generation phase. > > In cases where we get a tb, we can clear the traceback at the end of the > except clause without needing to clear the exception, etc. Whether or > not the traceback exists as an attribute of the exception would then > become an implementation detail. For cases where we pass an exception > instance around, I would introduce a function called get_tb(e) (in > either sys or traceback) that takes the exception object and returns the > traceback. Whether or not it should print a warning unless the > keyword-only argument of 'yes_I_know_I_need_to_clear_the_traceback' is > provided and is True, or if it returns a weakref, I'll leave to someone > else's discretion.
That sounds like too much complexity (both the syntax proposal and the get_tb() API). With the new GC, clearing the traceback is really not all that important any more except in the vicinity of buggy code that expects that leaving a scope GC's its locals; apart from that it's more of a performance issue than anything else, so I don't see why we can't just have __traceback__ on the exception object. -- --Guido van Rossum (home page: http://www.python.org/~guido/) _______________________________________________ Python-3000 mailing list Python-3000@python.org http://mail.python.org/mailman/listinfo/python-3000 Unsubscribe: http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com