diff options
author | Irit Katriel <iritkatriel@yahoo.com> | 2020-12-01 01:35:25 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-12-01 01:35:25 (GMT) |
commit | 427613f005f0f412d12f0d775d2b609bae0ae1ad (patch) | |
tree | 603c051eda2f8ee1717cdf58de01047184b79d2f /Lib/test/test_traceback.py | |
parent | 1244c816d7cdfa8a26d1671cab67122a8c5271a7 (diff) | |
download | cpython-427613f005f0f412d12f0d775d2b609bae0ae1ad.zip cpython-427613f005f0f412d12f0d775d2b609bae0ae1ad.tar.gz cpython-427613f005f0f412d12f0d775d2b609bae0ae1ad.tar.bz2 |
bpo-42482: remove reference to exc_traceback from TracebackException (GH-23531)
Diffstat (limited to 'Lib/test/test_traceback.py')
-rw-r--r-- | Lib/test/test_traceback.py | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/Lib/test/test_traceback.py b/Lib/test/test_traceback.py index f86afc6..5df701c 100644 --- a/Lib/test/test_traceback.py +++ b/Lib/test/test_traceback.py @@ -1123,6 +1123,18 @@ class TestTracebackException(unittest.TestCase): self.assertEqual(exc_info[0], exc.exc_type) self.assertEqual(str(exc_info[1]), str(exc)) + def test_no_refs_to_exception_and_traceback_objects(self): + try: + 1/0 + except Exception: + exc_info = sys.exc_info() + + refcnt1 = sys.getrefcount(exc_info[1]) + refcnt2 = sys.getrefcount(exc_info[2]) + exc = traceback.TracebackException(*exc_info) + self.assertEqual(sys.getrefcount(exc_info[1]), refcnt1) + self.assertEqual(sys.getrefcount(exc_info[2]), refcnt2) + def test_comparison_basic(self): try: 1/0 @@ -1172,6 +1184,16 @@ class TestTracebackException(unittest.TestCase): exc7 = traceback.TracebackException(*exc_info, limit=-2, capture_locals=True) self.assertNotEqual(exc6, exc7) + def test_comparison_equivalent_exceptions_are_equal(self): + excs = [] + for _ in range(2): + try: + 1/0 + except: + excs.append(traceback.TracebackException(*sys.exc_info())) + self.assertEqual(excs[0], excs[1]) + self.assertEqual(list(excs[0].format()), list(excs[1].format())) + def test_unhashable(self): class UnhashableException(Exception): def __eq__(self, other): |