Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Cleanup
  • Loading branch information
vstinner committed May 22, 2019
commit 5c1bf390e3a6a6842a21567d9074ebee5b1a2c28
3 changes: 0 additions & 3 deletions Lib/test/support/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3049,9 +3049,6 @@ class catch_unraisable_exception:
...

# cm.unraisable is None here (to break a reference cycle)

The finally block is required: cm.unraisable contains a traceback object
which indirectly references the 'cm' variable, it's a reference cycle.
"""

def __init__(self):
Expand Down
19 changes: 5 additions & 14 deletions Lib/test/test_exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -1184,21 +1184,12 @@ def __del__(self):
# The following line is included in the traceback report:
raise exc

class BrokenExceptionDel:
def __del__(self):
exc = BrokenStrException()
# The following line is included in the traceback report:
raise exc

for test_class in (BrokenDel, BrokenExceptionDel):
with self.subTest(test_class):
obj = test_class()
with support.catch_unraisable_exception() as cm:
del obj
obj = BrokenDel()
with support.catch_unraisable_exception() as cm:
del obj

self.assertEqual(cm.unraisable.object,
test_class.__del__)
self.assertIsNotNone(cm.unraisable.exc_traceback)
self.assertEqual(cm.unraisable.object, BrokenDel.__del__)
self.assertIsNotNone(cm.unraisable.exc_traceback)

def test_unhandled(self):
# Check for sensible reporting of unhandled exceptions
Expand Down
2 changes: 1 addition & 1 deletion Lib/test/test_generators.py
Original file line number Diff line number Diff line change
Expand Up @@ -2167,7 +2167,7 @@ def printsolution(self, x):
... l = Leaker()
... del l
...
... Leaker.__del__ == cm.unraisable.object
... cm.unraisable.object == Leaker.__del__
... cm.unraisable.exc_type == RuntimeError
... str(cm.unraisable.exc_value) == "del failed"
... cm.unraisable.exc_traceback is not None
Expand Down