Skip to content

Commit

Permalink
Tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
jobh committed May 31, 2024
1 parent 55fd562 commit dd971f5
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -435,15 +435,15 @@ def gc_callback(phase, info):
_gc_start = now
elif phase == "stop" and _gc_start > 0:
_gc_cumulative_time += now - _gc_start
except RecursionError:
except RecursionError: # pragma: no cover
# Avoid flakiness via UnraisableException, which is caught and
# warned by pytest. The actual callback (this function) is
# validated to never trigger a RecursionError itself when
# when called by gc.collect.
# Anyway, we should hit the same error on "start"
# and "stop", but to ensure we don't get out of sync we just
# signal that there is no matching start.
_gc_start = -1
_gc_start = 0
return

gc.callbacks.insert(0, gc_callback)
Expand Down
5 changes: 4 additions & 1 deletion hypothesis-python/src/hypothesis/internal/escalation.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,12 @@ def get_trimmed_traceback(exception=None):
else:
tb = exception.__traceback__
# Avoid trimming the traceback if we're in verbose mode, or the error
# was raised inside Hypothesis
# was raised inside Hypothesis. Additionally, the environment variable
# HYPOTHESIS_NO_TRACEBACK_TRIM is respected if nonempty, because verbose
# mode is prohibitively slow when debugging strategy recursion errors.
if (
tb is None
or os.environ.get("HYPOTHESIS_NO_TRACEBACK_TRIM", None)
or hypothesis.settings.default.verbosity >= hypothesis.Verbosity.debug
or is_hypothesis_file(traceback.extract_tb(tb)[-1][0])
and not isinstance(exception, _Trimmable)
Expand Down
2 changes: 1 addition & 1 deletion hypothesis-python/tests/nocover/test_recursive.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ def gen_cycles():
# of reference cycles, to trigger GC (if enabled). Beware: there may not
# even be room for raising new exceptions here, anything will end up as
# a RecursionError.
for i in range(NUM_CYCLES):
for _ in range(NUM_CYCLES):
a = [None]
b = [a]
a[0] = b
Expand Down

0 comments on commit dd971f5

Please sign in to comment.