bpo-45614: Fix traceback display for exceptions with invalid module name (GH-29726) (GH-29827)

(cherry picked from commit 4dfae6f38e)
This commit is contained in:
Irit Katriel 2021-11-29 10:11:48 +00:00 committed by GitHub
parent 209cec8a2a
commit 5b6aa6ce20
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 15 additions and 1 deletions

View file

@ -574,6 +574,8 @@ class TracebackException:
stype = self.exc_type.__qualname__
smod = self.exc_type.__module__
if smod not in ("__main__", "builtins"):
if not isinstance(smod, str):
smod = "<unknown>"
stype = smod + '.' + stype
if not issubclass(self.exc_type, SyntaxError):