Skip to content

Commit

Permalink
remove all buffer usages
Browse files Browse the repository at this point in the history
  • Loading branch information
tybug committed Jan 24, 2025
1 parent 50594d7 commit ad1cca1
Show file tree
Hide file tree
Showing 19 changed files with 156 additions and 676 deletions.
3 changes: 3 additions & 0 deletions hypothesis-python/RELEASE.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
RELEASE_TYPE: patch

Refactoring of our internal input generation. This shouldn't lead to any changes in the distribution of test inputs. If you notice any, please open an issue!
1 change: 0 additions & 1 deletion hypothesis-python/src/hypothesis/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -1869,7 +1869,6 @@ def fuzz_one_input(
assert isinstance(buffer, (bytes, bytearray, memoryview))
data = ConjectureData(
max_length=BUFFER_SIZE,
prefix=b"",
random=None,
provider=BytestringProvider,
provider_kw={"bytestring": buffer},
Expand Down
13 changes: 3 additions & 10 deletions hypothesis-python/src/hypothesis/internal/conjecture/choice.py
Original file line number Diff line number Diff line change
Expand Up @@ -418,16 +418,9 @@ def choice_permitted(choice: ChoiceT, kwargs: ChoiceKwargsT) -> bool:
kwargs = cast(IntegerKWargs, kwargs)
min_value = kwargs["min_value"]
max_value = kwargs["max_value"]
shrink_towards = kwargs["shrink_towards"]
if min_value is not None and choice < min_value:
return False
if max_value is not None and choice > max_value:
return False

if max_value is None or min_value is None:
return (choice - shrink_towards).bit_length() < 128

return True
return not (max_value is not None and choice > max_value)
elif isinstance(choice, float):
kwargs = cast(FloatKWargs, kwargs)
if math.isnan(choice):
Expand All @@ -450,9 +443,9 @@ def choice_permitted(choice: ChoiceT, kwargs: ChoiceKwargsT) -> bool:
return kwargs["max_size"] is None or len(choice) <= kwargs["max_size"]
elif isinstance(choice, bool):
kwargs = cast(BooleanKWargs, kwargs)
if kwargs["p"] <= 2 ** (-64):
if kwargs["p"] <= 0:
return choice is False
if kwargs["p"] >= (1 - 2 ** (-64)):
if kwargs["p"] >= 1:
return choice is True
return True
else:
Expand Down
Loading

0 comments on commit ad1cca1

Please sign in to comment.