mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
bpo-45614: Fix traceback display for exceptions with invalid module name (GH-29726)
This commit is contained in:
parent
e71c12efcd
commit
4dfae6f38e
4 changed files with 15 additions and 1 deletions
|
@ -1254,6 +1254,17 @@ class BaseExceptionReportingTests:
|
|||
exp = "%s: %s\n" % (str_name, str_value)
|
||||
self.assertEqual(exp, err)
|
||||
|
||||
def test_exception_modulename_not_unicode(self):
|
||||
class X(Exception):
|
||||
def __str__(self):
|
||||
return "I am X"
|
||||
|
||||
X.__module__ = 42
|
||||
|
||||
err = self.get_report(X())
|
||||
exp = f'<unknown>.{X.__qualname__}: I am X\n'
|
||||
self.assertEqual(exp, err)
|
||||
|
||||
def test_exception_bad__str__(self):
|
||||
class X(Exception):
|
||||
def __str__(self):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue