[New-bugs-announce] [issue46328] add sys.exception()

Irit Katriel report at bugs.python.org
Mon Jan 10 06:50:17 EST 2022


New submission from Irit Katriel <iritkatriel at gmail.com>:

Following to changes in issue45711, the interpreter's internal representation of the active exception is just the exception instance (the exc_type and exc_traceback fields were removed).

For backwards compatibility, sys.exc_info() constructs the (typ, val, tb) tuple from the instance and this will continue to be the case for some time because this tuple has leaked into quite a few APIs.

However, now that the redundancy in the exc_info tuple is guaranteed by the way it's constructed, we can confidently add a sys.exception() method that returns just the exception instance (as suggested in PEP3134's section on future improvements).

This small change will make a difference to learners because the (typ, val, tb) tuple looks quite cryptic to those who don't know about tracebacks, and the redundancy in it is confusing for those who do.

----------
assignee: iritkatriel
messages: 410204
nosy: iritkatriel
priority: normal
severity: normal
status: open
title: add sys.exception()
type: enhancement
versions: Python 3.11

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue46328>
_______________________________________


More information about the New-bugs-announce mailing list