summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_traceback.py
diff options
context:
space:
mode:
authorIrit Katriel <1055913+iritkatriel@users.noreply.github.com>2021-11-27 22:00:10 (GMT)
committerGitHub <noreply@github.com>2021-11-27 22:00:10 (GMT)
commit4dfae6f38e1720ddafcdd68043e476ecb41cb4d5 (patch)
treef4b3c2b296051e5f4ac3e4fdc9f4183758f65b4a /Lib/test/test_traceback.py
parente71c12efcddc1076d5367461a5b416092267aa77 (diff)
downloadcpython-4dfae6f38e1720ddafcdd68043e476ecb41cb4d5.zip
cpython-4dfae6f38e1720ddafcdd68043e476ecb41cb4d5.tar.gz
cpython-4dfae6f38e1720ddafcdd68043e476ecb41cb4d5.tar.bz2
bpo-45614: Fix traceback display for exceptions with invalid module name (GH-29726)
Diffstat (limited to 'Lib/test/test_traceback.py')
-rw-r--r--Lib/test/test_traceback.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/Lib/test/test_traceback.py b/Lib/test/test_traceback.py
index d88851d..cde35f5 100644
--- a/Lib/test/test_traceback.py
+++ b/Lib/test/test_traceback.py
@@ -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):