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

q can't write big strings in Python 3.12: "TypeError: 'float' object cannot be interpreted as an integer" #71

Open
alexwlchan opened this issue Jul 3, 2024 · 0 comments

Comments

@alexwlchan
Copy link

File to reproduce:

# example.py
import q
x = 'a' * 81
q.q(x)

Steps to reproduce:

$ python3.12 -m venv .venv
$ source .venv/bin/activate
$ pip install q
Collecting q
  Using cached q-2.7-py2.py3-none-any.whl.metadata (811 bytes)
Using cached q-2.7-py2.py3-none-any.whl (10 kB)
Installing collected packages: q
Successfully installed q-2.7

$ python3.12 example.py
Traceback (most recent call last):
  File "/private/var/folders/lp/1yl_g9ls2_g3l2tkmb6fpg0h0000gn/T/tmp.Jf4R2cEjpE/example.py", line 3, in <module>
    q.q(x)
  File "/private/var/folders/lp/1yl_g9ls2_g3l2tkmb6fpg0h0000gn/T/tmp.Jf4R2cEjpE/.venv/lib/python3.12/site-packages/q.py", line 357, in __call__
    self.show(info.function, args, labels)
  File "/private/var/folders/lp/1yl_g9ls2_g3l2tkmb6fpg0h0000gn/T/tmp.Jf4R2cEjpE/.venv/lib/python3.12/site-packages/q.py", line 272, in show
    for label, repr in zip(labels, reprs):
  File "/private/var/folders/lp/1yl_g9ls2_g3l2tkmb6fpg0h0000gn/T/tmp.Jf4R2cEjpE/.venv/lib/python3.12/site-packages/q.py", line 229, in safe_repr
    path = self.OUTPUT_PATH + '%08d.txt' % self.random.randrange(1e8)
                                           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/[email protected]/3.12.4/Frameworks/Python.framework/Versions/3.12/lib/python3.12/random.py", line 301, in randrange
    istart = _index(start)
             ^^^^^^^^^^^^^
TypeError: 'float' object cannot be interpreted as an integer

This is because randrange changed in Python 3.12, and it no longer converts non-integers to integers automatically.

This was fixed in q over a year ago (b8b7a7e) but the fix was never released to PyPI.

Could we get a release with the fix please?

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