[Python-Dev] PEP 344: Explicit vs. Implicit Chaining

Guido van Rossum gvanrossum at gmail.com
Fri May 20 18:37:48 CEST 2005


[Guido van Rossum]
> > Do we really need both __context__ and __cause__?

[Ka-Ping Yee]
> 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.
> 
> If we also want to provide the facility that Java and C# provide
> with initCause/InnerException, then we need a separate attribute
> devoted to explicit chaining.  The Java and C# documentation is
> clear that the cause/inner exception is to be set only on an
> exception that is "caused" or a "direct result" of the primary
> exception, which i've taken as a sign that this is an important
> distinction.
> 
> I wanted to give a shot at making both camps happy.
> 
> If the two were unified, we'd still be better off than we are
> now, but we should be aware that we would not be providing the
> functionality that Java and C# provide.

But what difference does it make in practice? In first approximation,
the only time the context is interesting is when a traceback is
printed. Since you propose to print __context__ when __cause__ isn't
set, from the POV of the user reading the traceback the effect is the
same as if there was only one link (let's call it __cause__) and the
APIs for setting it simply override the default.

(PS I'm still thinking about the equivalence of the chaining
algorithms; I've got a proof sketch in my head but getting the details
in email is taking time.)

-- 
--Guido van Rossum (home page: http://www.python.org/~guido/)


More information about the Python-Dev mailing list