mirror of
https://github.com/python/cpython.git
synced 2025-12-08 06:10:17 +00:00
bpo-45614: Fix traceback display for exceptions with invalid module name (GH-29726) (GH-29826)
(cherry picked from commit 4dfae6f38e)
This commit is contained in:
parent
305236e03a
commit
4d2cc3ed46
4 changed files with 15 additions and 1 deletions
|
|
@ -785,6 +785,17 @@ def test_message_none(self):
|
|||
err = self.get_report(Exception(''))
|
||||
self.assertIn('Exception\n', 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_syntax_error_various_offsets(self):
|
||||
for offset in range(-5, 10):
|
||||
for add in [0, 2]:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue