diff --git a/hypothesis-python/src/hypothesis/internal/conjecture/junkdrawer.py b/hypothesis-python/src/hypothesis/internal/conjecture/junkdrawer.py index 10fcb69421..2ab0e5cf48 100644 --- a/hypothesis-python/src/hypothesis/internal/conjecture/junkdrawer.py +++ b/hypothesis-python/src/hypothesis/internal/conjecture/junkdrawer.py @@ -435,7 +435,7 @@ 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 @@ -443,7 +443,7 @@ def gc_callback(phase, info): # 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) diff --git a/hypothesis-python/src/hypothesis/internal/escalation.py b/hypothesis-python/src/hypothesis/internal/escalation.py index c3c678d239..b85d9fcdc9 100644 --- a/hypothesis-python/src/hypothesis/internal/escalation.py +++ b/hypothesis-python/src/hypothesis/internal/escalation.py @@ -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) diff --git a/hypothesis-python/tests/nocover/test_recursive.py b/hypothesis-python/tests/nocover/test_recursive.py index 1c3f58a87b..021c682d56 100644 --- a/hypothesis-python/tests/nocover/test_recursive.py +++ b/hypothesis-python/tests/nocover/test_recursive.py @@ -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