Skip to content

Commit dd971f5

Browse files
committed
Tweaks
1 parent 55fd562 commit dd971f5

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

hypothesis-python/src/hypothesis/internal/conjecture/junkdrawer.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -435,15 +435,15 @@ def gc_callback(phase, info):
435435
_gc_start = now
436436
elif phase == "stop" and _gc_start > 0:
437437
_gc_cumulative_time += now - _gc_start
438-
except RecursionError:
438+
except RecursionError: # pragma: no cover
439439
# Avoid flakiness via UnraisableException, which is caught and
440440
# warned by pytest. The actual callback (this function) is
441441
# validated to never trigger a RecursionError itself when
442442
# when called by gc.collect.
443443
# Anyway, we should hit the same error on "start"
444444
# and "stop", but to ensure we don't get out of sync we just
445445
# signal that there is no matching start.
446-
_gc_start = -1
446+
_gc_start = 0
447447
return
448448

449449
gc.callbacks.insert(0, gc_callback)

hypothesis-python/src/hypothesis/internal/escalation.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,12 @@ def get_trimmed_traceback(exception=None):
8787
else:
8888
tb = exception.__traceback__
8989
# Avoid trimming the traceback if we're in verbose mode, or the error
90-
# was raised inside Hypothesis
90+
# was raised inside Hypothesis. Additionally, the environment variable
91+
# HYPOTHESIS_NO_TRACEBACK_TRIM is respected if nonempty, because verbose
92+
# mode is prohibitively slow when debugging strategy recursion errors.
9193
if (
9294
tb is None
95+
or os.environ.get("HYPOTHESIS_NO_TRACEBACK_TRIM", None)
9396
or hypothesis.settings.default.verbosity >= hypothesis.Verbosity.debug
9497
or is_hypothesis_file(traceback.extract_tb(tb)[-1][0])
9598
and not isinstance(exception, _Trimmable)

hypothesis-python/tests/nocover/test_recursive.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ def gen_cycles():
216216
# of reference cycles, to trigger GC (if enabled). Beware: there may not
217217
# even be room for raising new exceptions here, anything will end up as
218218
# a RecursionError.
219-
for i in range(NUM_CYCLES):
219+
for _ in range(NUM_CYCLES):
220220
a = [None]
221221
b = [a]
222222
a[0] = b

0 commit comments

Comments
 (0)