This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Inconsistency in C and python traceback printers
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 3.11, Python 3.10, Python 3.9
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: iritkatriel, msimacek, serhiy.storchaka
Priority: normal Keywords: patch

Created on 2020-06-19 08:54 by msimacek, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 28139 merged iritkatriel, 2021-09-03 12:32
Messages (2)
msg371855 - (view) Author: Michael Simacek (msimacek) Date: 2020-06-19 08:54
I belive the python traceback module was designed to produce the same output as the internal exception printer (sys.__excepthook__), but this is not the case when the exception's __str__ raises an exception.

Given an exception of the following class:
class E(Exception):
   def __str__(self):
      raise RuntimeError

Internal printer output:
Traceback (most recent call last):
  File "inconsistent.py", line 6, in <module>
    raise E()
__main__.E: <exception str() failed>

traceback.print_exc output:
Traceback (most recent call last):
  File "inconsistent.py", line 6, in <module>
    raise E()
E: <unprintable E object>
msg401091 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2021-09-05 15:54
New changeset 9e31b3952f6101ef71ec029481b972169ab0e0f1 by Irit Katriel in branch 'main':
bpo-41031: Match C and Python code formatting of unprintable exceptions and exceptions in the __main__ module. (GH-28139)
https://github.com/python/cpython/commit/9e31b3952f6101ef71ec029481b972169ab0e0f1
History
Date User Action Args
2022-04-11 14:59:32adminsetgithub: 85203
2021-09-08 15:11:03iritkatrielsetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2021-09-05 15:54:27serhiy.storchakasetnosy: + serhiy.storchaka
messages: + msg401091
2021-09-03 12:36:26iritkatrielsetversions: + Python 3.9, Python 3.11
2021-09-03 12:32:44iritkatrielsetkeywords: + patch
nosy: + iritkatriel

pull_requests: + pull_request26578
stage: patch review
2020-06-19 08:54:18msimacekcreate