bpo-45615: Add missing test for printing traceback for non-exception. Fix traceback.py (GH-30091)

This commit is contained in:
Irit Katriel 2022-01-02 09:34:03 +00:00 committed by GitHub
parent a09bc3a404
commit a82baed0e9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 28 additions and 7 deletions

View file

@ -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