[Python-Dev] except Exception as err, tb [was: with_traceback] (original) (raw)
Brett Cannon brett at python.org
Fri Mar 2 21:46:22 CET 2007
- Previous message: [Python-Dev] except Exception as err, tb [was: with_traceback]
- Next message: [Python-Dev] except Exception as err, tb [was: with_traceback]
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On 3/2/07, Jim Jewett <jimjjewett at gmail.com> wrote:
Guido van Rossum wrote:
> Since this can conceivably be going on in parallel in multiple > threads, we really don't ever want to be sharing whatever object > contains the head of the chain of tracebacks since it mutates at every > frame bubble-up. So (full) exceptions can't be unitary objects. In theory, raising an already-instantiated instance could indicate "no traceback", which could make pre-cooked exceptions even lighter. Otherwise, there is no way to make exceptions reference their traceback directly. Using a property which depends on both the exception and the frame asking (catching frame? thread?) is ... probably worse than keeping them separate. >>> except MyException as err, tb isn't so awful, and makes it clear that the traceback is no longer needed after the more typical >>> except MyException as err ... # no raise statements needing a context or cause
Just because it popped in my head, I think::
except Exception as exc with tb: ...
reads better.
-Brett
- Previous message: [Python-Dev] except Exception as err, tb [was: with_traceback]
- Next message: [Python-Dev] except Exception as err, tb [was: with_traceback]
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]