Terry Reedy wrote: > It sounds like you are asking for a special class > __NoException__(BaseException) to use as the marker. Guido van Rossum wrote: > So what did you think of Terry Reedy's idea of using a special exception class? Our table would then look like: __context__ __cause__ raise None __NoException__ reraise previous __NoException__ reraise from previous None | exception It is certainly simpler than trying to force the use of both True and False. :) The purist side of me thinks it's still slightly awkward; the practical side recognizes that there probably is not a perfect solution and thinks this is workable, and is willing to deal with the slight awkwardness to get 'from None' up and running. :) The main reason for the effort in keeping the previous exception in __context__ instead of just clobbering it is for custom error handlers, yes? So here is a brief comparison of the two: def complete_traceback(): .... Actually, I got about three lines into that and realized that whatever __cause__ is set to is completely irrelevant for that function: if *__context__* is not None, follow the chain; the only relevance __cause__ has is when would it print? If it is a (valid) exception. And how do we know if it's valid? # True, False, None if isinstance(exc.__cause__, BaseException): print_exc(exc) or if exc.__cause__ not in (True, False, None): print_exc(exc) vs # None, __NoException__ (forced to be an instance) if (exc.__cause__ is not None and not isinstance(exc.__cause__, __NoException__): print_exc(exc) or # None, __NoException__ (forced to stay a class) if exc.__cause__ not in (None, __NoException__): print_exc(exc) Having gone through all that, I'm equally willing to go either way (True/False/None or __NoException__). Implementation questions for the __NoException__ route: 1) Do we want double underscores, or just a single one? I'm thinking double to mark it as special as opposed to private. 2) This is a new exception class -- do we want to store the class itself in __context__, or it's instance? If its class, should we somehow disallow instantiation of it? 3) Should it be an exception, or just inherit from object? Is it worth worrying about somebody trying to raise it, or raise from it? 4) Is the name '__NoException__' confusing? ~Ethan~
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4