Message 406984 - Python tracker (original) (raw)

Following the analysis/discussion on https://github.com/faster-cpython/ideas/issues/106:

  1. sys.exc_info()[2] can currently be different from sys.exc_info()[1].traceback because changes to the latter (while an except clause is executing) don't show up in the former. This is arguably a bug, we will change it so that the type and traceback are always consistent with the exception.

  2. PyErr_SetExcInfo does no arg checking, and will set exc_info to an inconsistent triplet if you ask it to. However, the exc_value arg must be an exception instance so the only thing you can do is pass in nonsensical args where the type/traceback do not match the exception. This function's purpose is to save/restore exc_info. We will make it ignore the type and traceback and document that change.