diff options
author | Irit Katriel <1055913+iritkatriel@users.noreply.github.com> | 2023-03-18 11:47:11 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-03-18 11:47:11 (GMT) |
commit | e1e9bab0061e8d4bd7b94ed455f3bb7bf8633ae7 (patch) | |
tree | 8363c72cc70b34e06fed5c39d86ec99047613799 /Doc | |
parent | 039714d00f147be4d018fa6aeaf174aad7e8fa32 (diff) | |
download | cpython-e1e9bab0061e8d4bd7b94ed455f3bb7bf8633ae7.zip cpython-e1e9bab0061e8d4bd7b94ed455f3bb7bf8633ae7.tar.gz cpython-e1e9bab0061e8d4bd7b94ed455f3bb7bf8633ae7.tar.bz2 |
gh-102778: Add sys.last_exc, deprecate sys.last_type, sys.last_value,sys.last_traceback (#102779)
Diffstat (limited to 'Doc')
-rw-r--r-- | Doc/library/sys.rst | 25 | ||||
-rw-r--r-- | Doc/whatsnew/3.12.rst | 10 |
2 files changed, 24 insertions, 11 deletions
diff --git a/Doc/library/sys.rst b/Doc/library/sys.rst index a53d490..b3b9b5e 100644 --- a/Doc/library/sys.rst +++ b/Doc/library/sys.rst @@ -1102,22 +1102,25 @@ always available. .. versionadded:: 3.5 +.. data:: last_exc + + This variable is not always defined; it is set to the exception instance + when an exception is not handled and the interpreter prints an error message + and a stack traceback. Its intended use is to allow an interactive user to + import a debugger module and engage in post-mortem debugging without having + to re-execute the command that caused the error. (Typical use is + ``import pdb; pdb.pm()`` to enter the post-mortem debugger; see :mod:`pdb` + module for more information.) + + .. versionadded:: 3.12 .. data:: last_type last_value last_traceback - These three variables are not always defined; they are set when an exception is - not handled and the interpreter prints an error message and a stack traceback. - Their intended use is to allow an interactive user to import a debugger module - and engage in post-mortem debugging without having to re-execute the command - that caused the error. (Typical use is ``import pdb; pdb.pm()`` to enter the - post-mortem debugger; see :mod:`pdb` module for - more information.) - - The meaning of the variables is the same as that of the return values from - :func:`exc_info` above. - + These three variables are deprecated; use :data:`sys.last_exc` instead. + They hold the legacy representation of ``sys.last_exc``, as returned + from :func:`exc_info` above. .. data:: maxsize diff --git a/Doc/whatsnew/3.12.rst b/Doc/whatsnew/3.12.rst index b55b961..32fec96 100644 --- a/Doc/whatsnew/3.12.rst +++ b/Doc/whatsnew/3.12.rst @@ -397,6 +397,12 @@ sys with contributions from Gregory P. Smith [Google] and Mark Shannon in :gh:`96123`.) +* Add :data:`sys.last_exc` which holds the last unhandled exception that + was raised (for post-mortem debugging use cases). Deprecate the + three fields that have the same information in its legacy form: + :data:`sys.last_type`, :data:`sys.last_value` and :data:`sys.last_traceback`. + (Contributed by Irit Katriel in :gh:`102778`.) + Optimizations ============= @@ -488,6 +494,10 @@ Deprecated contain the creation time, which is also available in the new ``st_birthtime`` field. (Contributed by Steve Dower in :gh:`99726`.) +* The :data:`sys.last_type`, :data:`sys.last_value` and :data:`sys.last_traceback` + fields are deprecated. Use :data:`sys.last_exc` instead. + (Contributed by Irit Katriel in :gh:`102778`.) + Pending Removal in Python 3.13 ------------------------------ |