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 - Python 3.12 #2453

Open
bitcoinlizard opened this issue Jun 1, 2024 · 1 comment

Comments

@bitcoinlizard
Copy link

bitcoinlizard commented Jun 1, 2024

Describe the bug
I have been maintaining an Arch Linux package for Specter Desktop. Arch recently moved to Python 3.12 and I suspect the Python upgrade is responsible for a behavior change in random.py which breaks the run process.

To Reproduce
Steps to reproduce the behavior:
Run Specter Desktop with this command on Arch Linux running Python 3.12:
python -m cryptoadvance.specter server --debug

Expected behavior
Specter Desktop should run normally as it did in Python 3.11 on Arch Linux

Desktop (please complete the following information):

  • Arch Linux
  • Running at Arch Linux CLI
  • Specter Version 2.0.5

Additional context
Here is the full error message:
$ python -m cryptoadvance.specter server --debug
Traceback (most recent call last):
File "", line 198, in _run_module_as_main
File "", line 88, in _run_code
File "/usr/lib/python3.12/site-packages/cryptoadvance/specter/main.py", line 2, in
from .cli import entry_point
File "/usr/lib/python3.12/site-packages/cryptoadvance/specter/cli/init.py", line 6, in
from ..server import setup_logging
File "/usr/lib/python3.12/site-packages/cryptoadvance/specter/server.py", line 31, in
from .hwi_server import hwi_server
File "/usr/lib/python3.12/site-packages/cryptoadvance/specter/hwi_server.py", line 14, in
rand = random.randint(0, 1e32) # to force style refresh
^^^^^^^^^^^^^^^^^^^^^^^
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 312, in randrange
istop = _index(stop)
^^^^^^^^^^^^
TypeError: 'float' object cannot be interpreted as an integer

@bitcoinlizard
Copy link
Author

It seems that in Python 3.12 there was a change to the random library. "random.randint" will not accept "1e32" because the python exponent function returns an float instead of an integer. A work around would be to change the offending line to:

rand = random.randint(0, int(1e32))

This line is used in a number of spots in Specter.

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

1 participant