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

TypeError: 'float' object cannot be interpreted as an integer #44

Closed
StringManolo opened this issue Jun 19, 2024 · 5 comments
Closed

TypeError: 'float' object cannot be interpreted as an integer #44

StringManolo opened this issue Jun 19, 2024 · 5 comments

Comments

@StringManolo
Copy link

Got this error:

$ fierce --domain example.com
NS: a.iana-servers.net. b.iana-servers.net.
SOA: ns.icann.org. (199.4.138.53)
Zone: failure
Traceback (most recent call last):
  File "/usr/bin/fierce", line 33, in <module>
    sys.exit(load_entry_point('fierce==1.5.0', 'console_scripts', 'fierce')())
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/fierce-1.5.0-py3.12.egg/fierce/fierce.py", line 495, in main
    fierce(**vars(args))
  File "/usr/lib/python3.12/site-packages/fierce-1.5.0-py3.12.egg/fierce/fierce.py", line 338, in fierce
    random_subdomain = str(random.randint(1e10, 1e11))  # noqa DUO102, non-cryptographic random use
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/random.py", line 336, in randint
    return self.randrange(a, b+1)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/random.py", line 301, in randrange
    istart = _index(start)
             ^^^^^^^^^^^^^
TypeError: 'float' object cannot be interpreted as an integer

Fixed it by replacing:

random_subdomain = str(random.randint(1e10, 1e11)) 

by

random_subdomain = str(random.randint(10000000000, 99999999999))

The line is:

random_subdomain = str(random.randint(1e10, 1e11)) # noqa DUO102, non-cryptographic random use

@mschwager
Copy link
Owner

Ahh, interesting, I see random.randint's behavior changed in Python 3.12. Initially I thought that the scientific notation syntax changed it's type from int to float, but it appears that it's always been a float.

How do you feel about the following change instead?

random_subdomain = str(random.randint(int(1e10), int(1e11)))

It feels like it retains the original behavior slightly better to me. Would you be interested in opening a PR to fix it?

@StringManolo
Copy link
Author

Ahh, interesting, I see random.randint's behavior changed in Python 3.12. Initially I thought that the scientific notation syntax changed it's type from int to float, but it appears that it's always been a float.

How do you feel about the following change instead?

random_subdomain = str(random.randint(int(1e10), int(1e11)))

It feels like it retains the original behavior slightly better to me. Would you be interested in opening a PR to fix it?

Ye, that solution is much better.

@superswan
Copy link

hello, still having this issue but it works with the suggested fix
random_subdomain = str(random.randint(int(1e10), int(1e11)))

@mschwager
Copy link
Owner

hello, still having this issue but it works with the suggested fix random_subdomain = str(random.randint(int(1e10), int(1e11)))

Thanks for the confirmation, I'll fix this tomorrow and release a new version.

@mschwager
Copy link
Owner

Version 1.6.0 has been released with the fix: https://pypi.org/project/fierce/1.6.0/

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

3 participants