Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RecursionError: maximum recursion depth exceeded in comparison #1926

Closed
jonykalavera opened this issue Oct 11, 2023 · 2 comments
Closed

RecursionError: maximum recursion depth exceeded in comparison #1926

jonykalavera opened this issue Oct 11, 2023 · 2 comments

Comments

@jonykalavera
Copy link

jonykalavera commented Oct 11, 2023

  • Faker version: >= 19.6.2
  • OS: Linux

Generating a float with max_value=1.0 and left_digits=1 raises a recursion error. This was not the behavior of previous releases.

Steps to reproduce

>>> from faker import Faker
>>> Faker().pyfloat(left_digits=1, max_value=1.0)
Traceback (most recent call last):
  File "/home/luis/.pyenv/versions/3.10.4/lib/python3.10/code.py", line 90, in runcode
    exec(code, self.locals)
  File "<console>", line 1, in <module>
  File "/home/luis/.cache/pypoetry/virtualenvs/csi-q5090HDc-py3.10/lib/python3.10/site-packages/faker/providers/python/__init__.py", line 217, in pyfloat
    positive_number = self._safe_random_int(
  File "/home/luis/.cache/pypoetry/virtualenvs/csi-q5090HDc-py3.10/lib/python3.10/site-packages/faker/providers/python/__init__.py", line 282, in _safe_random_int
    return self._safe_random_int(orig_min_value, orig_max_value, positive)
  File "/home/luis/.cache/pypoetry/virtualenvs/csi-q5090HDc-py3.10/lib/python3.10/site-packages/faker/providers/python/__init__.py", line 282, in _safe_random_int
    return self._safe_random_int(orig_min_value, orig_max_value, positive)
  File "/home/luis/.cache/pypoetry/virtualenvs/csi-q5090HDc-py3.10/lib/python3.10/site-packages/faker/providers/python/__init__.py", line 282, in _safe_random_int
    return self._safe_random_int(orig_min_value, orig_max_value, positive)
  [Previous line repeated 978 more times]
  File "/home/luis/.cache/pypoetry/virtualenvs/csi-q5090HDc-py3.10/lib/python3.10/site-packages/faker/providers/python/__init__.py", line 279, in _safe_random_int
    min_value = max(min_value, 0)

Expected behavior

Should return a float value < 1.0

Actual behavior

Raises RecursionError

@jonykalavera
Copy link
Author

This PR seems to be the origin of this issue #1908

@jonykalavera
Copy link
Author

Wow @fcurella !! you work fast!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants