bpo-30639: Lazily compute repr for error (#2132) · python/cpython@e968bc7 · GitHub
Skip to content

Commit e968bc7

Browse files
takluyverYury Selivanov
authored andcommitted
bpo-30639: Lazily compute repr for error (#2132)
1 parent 8e482be commit e968bc7

3 files changed

Lines changed: 13 additions & 2 deletions

File tree

Lib/inspect.py

Lines changed: 3 additions & 2 deletions

Lib/test/test_inspect.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -463,6 +463,14 @@ class C(metaclass=CM):
463463
with self.assertRaises(TypeError):
464464
inspect.getfile(C)
465465

466+
def test_getfile_broken_repr(self):
467+
class ErrorRepr:
468+
def __repr__(self):
469+
raise Exception('xyz')
470+
er = ErrorRepr()
471+
with self.assertRaises(TypeError):
472+
inspect.getfile(er)
473+
466474
def test_getmodule_recursion(self):
467475
from types import ModuleType
468476
name = '__inspect_dummy'
Lines changed: 2 additions & 0 deletions

0 commit comments

Comments
 (0)