diff options
author | Irit Katriel <1055913+iritkatriel@users.noreply.github.com> | 2023-03-18 07:19:38 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-03-18 07:19:38 (GMT) |
commit | b3cc11a08e1e9121ddba3b9afb9fae032e86f449 (patch) | |
tree | e4993f932a173d482f06e797b9587a33aa7f0491 /Lib/test/test_exceptions.py | |
parent | 72186aa637bc88cd5f5e234803af64acab25994c (diff) | |
download | cpython-b3cc11a08e1e9121ddba3b9afb9fae032e86f449.zip cpython-b3cc11a08e1e9121ddba3b9afb9fae032e86f449.tar.gz cpython-b3cc11a08e1e9121ddba3b9afb9fae032e86f449.tar.bz2 |
gh-102799: remove unnecessary calls to sys.exc_info() in tests (#102800)
Diffstat (limited to 'Lib/test/test_exceptions.py')
-rw-r--r-- | Lib/test/test_exceptions.py | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/Lib/test/test_exceptions.py b/Lib/test/test_exceptions.py index 4ae71e4..284f26be 100644 --- a/Lib/test/test_exceptions.py +++ b/Lib/test/test_exceptions.py @@ -599,8 +599,8 @@ class ExceptionTests(unittest.TestCase): def testWithTraceback(self): try: raise IndexError(4) - except: - tb = sys.exc_info()[2] + except Exception as e: + tb = e.__traceback__ e = BaseException().with_traceback(tb) self.assertIsInstance(e, BaseException) @@ -653,8 +653,8 @@ class ExceptionTests(unittest.TestCase): def testNoneClearsTracebackAttr(self): try: raise IndexError(4) - except: - tb = sys.exc_info()[2] + except Exception as e: + tb = e.__traceback__ e = Exception() e.__traceback__ = tb @@ -1337,11 +1337,11 @@ class ExceptionTests(unittest.TestCase): def g(): try: return g() - except RecursionError: - return sys.exc_info() - e, v, tb = g() - self.assertIsInstance(v, RecursionError, type(v)) - self.assertIn("maximum recursion depth exceeded", str(v)) + except RecursionError as e: + return e + exc = g() + self.assertIsInstance(exc, RecursionError, type(exc)) + self.assertIn("maximum recursion depth exceeded", str(exc)) @cpython_only |