[Python-Dev] PEP 409 - final? (original) (raw)
Ethan Furman ethan at stoneleaf.us
Wed Feb 1 21:55:49 CET 2012
- Previous message: [Python-Dev] PEP 409 - final?
- Next message: [Python-Dev] PEP 409 - final?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Guido van Rossum wrote:
On Wed, Feb 1, 2012 at 10:48 AM, Ethan Furman <ethan at stoneleaf.us> wrote:
My apologies for my ignorance, but is the code smell because both False and None evaluate to bool(False)? That's part of it, but the other part is that the type of context is now truly dynamic. I often think of variables as having some static type, e.g. "integer" or "Foo instance", and for most Foo instances I consider None an acceptable value (since that's how pointer types work in most static languages). But the type of context you're proposing is now a union of exception and bool, except that the bool can only be False. It seems you really need a marker object. I'd be fine with using some other opaque marker -- IMO that's much better than using False but disallowing True.
So for cause we need three values:
Not set special value (prints context if present)
Some exception (print instead of context)
Ignore context special value (and stop following the context chain)
For (3) we're hoping for None, for (2) we have an actual exception, and for (1) -- hmmm.
It seems like a stretch, but we could do (looking at both context and cause):
__context__ __cause__
raise None False [1]
reraise previous True [2]
reraise from previous None [3] | exception
[1] False means non-chained exception [2] True means chained exception [3] None means chained exception, but by default we do not print nor follow the chain
The downside to this is that effectively either False and True mean the same thing, i.e. try to follow the context chain, or False and None mean the same thing, i.e. don't bother trying to follow the context chain because it either doesn't exist or is being suppressed.
Feels like a bunch of complexity for marginal value. As you were saying, some other object to replace both False and True in the above table would be ideal.
Ethan
- Previous message: [Python-Dev] PEP 409 - final?
- Next message: [Python-Dev] PEP 409 - final?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]