gvellut / jncep

Command-line tool to generate EPUB files for J-Novel Club pre-pub novels
GNU General Public License v3.0
43 stars 11 forks source link

Invoking jncep throws a TypeError with python 3.12 #45

Closed non-Jedi closed 11 months ago

non-Jedi commented 11 months ago

Describe the bug When invoking jncep with python 3.12, a TypeError is always thrown by import asks:

jncep --help
Traceback (most recent call last):
  File "/home/adam/.venvs/jncep/bin/jncep", line 5, in <module>
    from jncep.jncep import main
  File "/home/adam/.venvs/jncep/lib/python3.12/site-packages/jncep/jncep.py", line 6, in <module>
    from .cli.config import config_manage
  File "/home/adam/.venvs/jncep/lib/python3.12/site-packages/jncep/cli/config.py", line 5, in <module>
    from .. import config, track, utils
  File "/home/adam/.venvs/jncep/lib/python3.12/site-packages/jncep/track.py", line 11, in <module>
    from . import config, core, jncweb, spec, utils
  File "/home/adam/.venvs/jncep/lib/python3.12/site-packages/jncep/core.py", line 17, in <module>
    from . import epub, jnclabs, jncweb, spec, utils
  File "/home/adam/.venvs/jncep/lib/python3.12/site-packages/jncep/jnclabs.py", line 6, in <module>
    import asks
  File "/home/adam/.venvs/jncep/lib/python3.12/site-packages/asks/__init__.py", line 5, in <module>
    from .base_funcs import *
  File "/home/adam/.venvs/jncep/lib/python3.12/site-packages/asks/base_funcs.py", line 8, in <module>
    from .sessions import Session
  File "/home/adam/.venvs/jncep/lib/python3.12/site-packages/asks/sessions.py", line 16, in <module>
    from .request_object import RequestProcessor
  File "/home/adam/.venvs/jncep/lib/python3.12/site-packages/asks/request_object.py", line 31, in <module>
    _BOUNDARY = "8banana133744910kmmr13a56!102!" + str(randint(1e3, 9e3))
                                                       ^^^^^^^^^^^^^^^^^
  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

The issue is that jncep is installed with asks 2.4.12 which doesn't have the commit which fixes this issue. I believe upgrading to asks 3.0.0 should fix the problem, but I'm unsure if there are breaking changes in the asks library between 2.4.12 and 3.0.0.

Expected behavior jncep should work as it has with previous versions of python.

To Reproduce

  1. Install python 3.12.0.
  2. Create venv: python -m venv jncep-venv
  3. Activate venv: source jncep-venv/bin/activate.fish
  4. Install jncep: pip install jncep
  5. jncep --help

Environment (please complete the following information):

non-Jedi commented 11 months ago

I went ahead and forced upgrading to asks 3.0.0 locally (pip install -U asks with venv activated), and jncep seems to be working as expected thus far. My current workflow only uses the jncep epub subcommand though, so there may still be dragons here.

gvellut commented 11 months ago

Thank you for your feedback.

I will update the requirements and test the other commands with the new asks version.