On May 20, 2005, at 4:31 AM, Ka-Ping Yee wrote:
> Guido van Rossum wrote:
>
>> Do we really need both __context__ and __cause__?
>>
>
> Well, it depends whose needs we're trying to meet.
>
> If we want to satisfy those who have been asking for chaining
> of unexpected secondary exceptions, then we have to provide that
> on some attribute.
I still don't see why people think the python interpreter should be
automatically providing __context__. To me it seems like it'll just
clutter things up for no good reason. If you really want the other
exception, you can access it via the local variable in the frame
where it was first caught. Of course right now you don't get a
traceback, but the proposal fixes that.
>>> def test():
... try:
... 1/0
... except Exception, e:
... y
...
>>> test()
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "<stdin>", line 5, in test
NameError: global name 'y' is not defined
>>> pdb.pm()
> <stdin>(5)test()
(Pdb) locals()
{'e': <exceptions.ZeroDivisionError instance at 0x73198>}
James
_______________________________________________
Python-Dev mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe:
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com