summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_argparse.py
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2022-01-18 07:29:02 (GMT)
committerGitHub <noreply@github.com>2022-01-18 07:29:02 (GMT)
commit1d6530dd0564a6bb75989b9fca25a649b5ddc1b0 (patch)
treeac21f01b040449cb8df4f8c0a15cf5f3a4618cd6 /Lib/test/test_argparse.py
parent0fbb9afbddb93408e34bdb7625002374cb2ad68c (diff)
downloadcpython-1d6530dd0564a6bb75989b9fca25a649b5ddc1b0.zip
cpython-1d6530dd0564a6bb75989b9fca25a649b5ddc1b0.tar.gz
cpython-1d6530dd0564a6bb75989b9fca25a649b5ddc1b0.tar.bz2
[3.9] bpo-46411: Remove unnecessary calls to sys.exc_info() in tests (GH-30638) (GH-30658)
(cherry picked from commit a287b31bcb065e4122400cb59167340d25480e6d) Co-authored-by: Irit Katriel <1055913+iritkatriel@users.noreply.github.com> Automerge-Triggered-By: GH:iritkatriel
Diffstat (limited to 'Lib/test/test_argparse.py')
-rw-r--r--Lib/test/test_argparse.py10
1 files changed, 4 insertions, 6 deletions
diff --git a/Lib/test/test_argparse.py b/Lib/test/test_argparse.py
index 043a9cf..cc5e849 100644
--- a/Lib/test/test_argparse.py
+++ b/Lib/test/test_argparse.py
@@ -101,8 +101,8 @@ def stderr_to_parser_error(parse_args, *args, **kwargs):
if getattr(result, key) is sys.stderr:
setattr(result, key, old_stderr)
return result
- except SystemExit:
- code = sys.exc_info()[1].code
+ except SystemExit as e:
+ code = e.code
stdout = sys.stdout.getvalue()
stderr = sys.stderr.getvalue()
raise ArgumentParserError(
@@ -1828,8 +1828,7 @@ class TestActionUserDefined(ParserTestCase):
raise AssertionError('value: %s' % value)
assert expected_ns == namespace, ('expected %s, got %s' %
(expected_ns, namespace))
- except AssertionError:
- e = sys.exc_info()[1]
+ except AssertionError as e:
raise ArgumentParserError('opt_action failed: %s' % e)
setattr(namespace, 'spam', value)
@@ -1854,8 +1853,7 @@ class TestActionUserDefined(ParserTestCase):
raise AssertionError('value: %s' % value)
assert expected_ns == namespace, ('expected %s, got %s' %
(expected_ns, namespace))
- except AssertionError:
- e = sys.exc_info()[1]
+ except AssertionError as e:
raise ArgumentParserError('arg_action failed: %s' % e)
setattr(namespace, 'badger', value)