On 3/2/07, Andrew Dalke <[EMAIL PROTECTED]> wrote: > On 3/2/07, Guido van Rossum <[EMAIL PROTECTED]> wrote: > > So, despite the existence of libraries that pre-create exceptions, how > > bad would it really be if we declared that use unsafe? It wouldn't be > > hard to add some kind of boobytrap that goes off when pre-created > > exceptions are raised multiple times. If this had always been the > > semantics I'm sure nobody would have complained and I doubt that it > > would have been a common pitfall either (since if it doesn't work, > > there's no bad code abusing it, and so there are no bad examples that > > newbies could unwittingly emulate). > > Here's code from os._execvpe which reraises an exception > instance which was created earlier > > saved_exc = None > saved_tb = None > for dir in PATH: > fullname = path.join(dir, file) > try: > func(fullname, *argrest) > except error, e: > tb = sys.exc_info()[2] > if (e.errno != ENOENT and e.errno != ENOTDIR > and saved_exc is None): > saved_exc = e > saved_tb = tb > if saved_exc: > raise error, saved_exc, saved_tb > raise error, e, tb > > Would the boobytrap go off in this case? I think it would, > because a "saved_exc" is raised twice.
It shouldn't. This is a requirement for the boobytrap (which is vaporware as yet :-). Perhaps we could allow reraising whenever the existing traceback chain contains a reference to a frame that is an ancestor of (or equal to) the newly raising frame? -- --Guido van Rossum (home page: http://www.python.org/~guido/) _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com