mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
Issue #9815: assertRaises now tries to clear references to local variables in the exception's traceback.
This commit is contained in:
parent
871dfc41d3
commit
9681022f1e
3 changed files with 37 additions and 0 deletions
|
@ -9,6 +9,7 @@ import re
|
|||
import warnings
|
||||
import collections
|
||||
import contextlib
|
||||
import traceback
|
||||
|
||||
from . import result
|
||||
from .util import (strclass, safe_repr, _count_diff_all_purpose,
|
||||
|
@ -178,6 +179,8 @@ class _AssertRaisesContext(_AssertRaisesBaseContext):
|
|||
self.obj_name))
|
||||
else:
|
||||
self._raiseFailure("{} not raised".format(exc_name))
|
||||
else:
|
||||
traceback.clear_frames(tb)
|
||||
if not issubclass(exc_type, self.expected):
|
||||
# let unexpected exceptions pass through
|
||||
return False
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue