diff options
author | Irit Katriel <1055913+iritkatriel@users.noreply.github.com> | 2022-01-02 09:34:03 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-01-02 09:34:03 (GMT) |
commit | a82baed0e9e61c0d8dc5c12fc08de7fc172c1a38 (patch) | |
tree | 6d77ee7bd890b54d0c51bda794b7eb3120387569 /Lib/traceback.py | |
parent | a09bc3a404befca197b5d9959a9c62110ee61d77 (diff) | |
download | cpython-a82baed0e9e61c0d8dc5c12fc08de7fc172c1a38.zip cpython-a82baed0e9e61c0d8dc5c12fc08de7fc172c1a38.tar.gz cpython-a82baed0e9e61c0d8dc5c12fc08de7fc172c1a38.tar.bz2 |
bpo-45615: Add missing test for printing traceback for non-exception. Fix traceback.py (GH-30091)
Diffstat (limited to 'Lib/traceback.py')
-rw-r--r-- | Lib/traceback.py | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/Lib/traceback.py b/Lib/traceback.py index b244750..05f1fff 100644 --- a/Lib/traceback.py +++ b/Lib/traceback.py @@ -98,7 +98,11 @@ def _parse_value_tb(exc, value, tb): raise ValueError("Both or neither of value and tb must be given") if value is tb is _sentinel: if exc is not None: - return exc, exc.__traceback__ + if isinstance(exc, BaseException): + return exc, exc.__traceback__ + + raise TypeError(f'Exception expected for value, ' + f'{type(exc).__name__} found') else: return None, None return value, tb |