Skip to content

Commit

Permalink
Finish fix and text for traceback error
Browse files Browse the repository at this point in the history
  • Loading branch information
Zac-HD committed Nov 14, 2022
1 parent 7d1c3ec commit 6760241
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
9 changes: 6 additions & 3 deletions hypothesis-python/src/hypothesis/internal/escalation.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,12 @@ def escalate_hypothesis_internal_error():
if PREVENT_ESCALATION:
return

error_type, e, tb = sys.exc_info()
_, e, tb = sys.exc_info()

if getattr(e, "hypothesis_internal_never_escalate", False):
return

filepath = traceback.extract_tb(tb)[-1][0]
filepath = None if tb is None else traceback.extract_tb(tb)[-1][0]
if is_hypothesis_file(filepath) and not isinstance(
e, (HypothesisException,) + HYPOTHESIS_CONTROL_EXCEPTIONS
):
Expand Down Expand Up @@ -113,7 +113,10 @@ def get_interesting_origin(exception):
# blocks and understand the __cause__ (`raise x from y`) or __context__ that
# first raised an exception as well as PEP-654 exception groups.
tb = get_trimmed_traceback(exception)
filename, lineno, *_ = traceback.extract_tb(tb)[-1]
if tb is None:
filename, lineno = None, None
else:
filename, lineno, *_ = traceback.extract_tb(tb)[-1]
return (
type(exception),
filename,
Expand Down
4 changes: 4 additions & 0 deletions hypothesis-python/tests/cover/test_escalation.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,7 @@ def test_multiplefailures_deprecation():
with pytest.warns(errors.HypothesisDeprecationWarning):
exc = errors.MultipleFailures
assert exc is BaseExceptionGroup


def test_handles_null_traceback():
esc.get_interesting_origin(Exception())

0 comments on commit 6760241

Please sign in to comment.