Skip to content

Commit b3d1296

Browse files
committed
Simplify minimal reproducer
1 parent 36a91ad commit b3d1296

File tree

1 file changed

+6
-12
lines changed

1 file changed

+6
-12
lines changed

Lib/test/test_traceback.py

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -527,22 +527,16 @@ def __del__(self):
527527
def test_when_io_is_lost(self):
528528
# GH-142737: Display the traceback even if io.open is lost
529529
code = textwrap.dedent("""\
530-
import builtins
531-
import sys
532-
533-
def bad_import(name, *args, **kwargs):
534-
sys.modules[name] = 42
535-
return sys.modules[name]
536-
537-
builtins.__import__ = bad_import
530+
import io
531+
import traceback
532+
traceback._print_exception_bltin = None
533+
del io.open
538534
raise RuntimeError("should not crash")
539535
""")
540536
rc, stdout, stderr = assert_python_failure('-c', code)
541537
self.assertEqual(rc, 1)
542-
expected = [b'Exception ignored in the internal traceback machinery:',
543-
b'AttributeError: \'int\' object has no attribute \'_print_exception_bltin\'',
544-
b'Traceback (most recent call last):',
545-
b' File "<string>", line 9, in <module>',
538+
expected = [b'Traceback (most recent call last):',
539+
b' File "<string>", line 5, in <module>',
546540
b'RuntimeError: should not crash']
547541
self.assertEqual(stderr.splitlines(), expected)
548542

0 commit comments

Comments
 (0)