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

KeyError on Python version 3.11.0 #214

Closed
4 tasks done
tilda opened this issue Oct 15, 2023 · 3 comments
Closed
4 tasks done

KeyError on Python version 3.11.0 #214

tilda opened this issue Oct 15, 2023 · 3 comments

Comments

@tilda
Copy link

tilda commented Oct 15, 2023

Summary

When running a bot using Python 3.11, Jishaku fails to load with a cryptic KeyError: +ClientT stemming from the pagination code.

Reproduction steps

Able to reproduce this using Python 3.11.0 on Debian bullseye/11. Issue does not happen on Python 3.10.8 (same distro, machine, dependencies, etc)

Expected results

No errors from Jishaku/module should load successfully.

Actual results

Traceback:

[2023-10-15 21:43:20.038247] INFO: maho: also loading jishaku
Traceback (most recent call last):
  File "/home/tilda/.local/share/virtualenvs/maho-RiUJz-OJ/lib/python3.11/site-packages/discord/ext/commands/bot.py", line 935, in _load_from_module_spec
    spec.loader.exec_module(lib)  # type: ignore
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap_external>", line 940, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/home/tilda/.local/share/virtualenvs/maho-RiUJz-OJ/lib/python3.11/site-packages/jishaku/__init__.py", line 15, in <module>
    from jishaku.cog import *  # noqa: F401
    ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/tilda/.local/share/virtualenvs/maho-RiUJz-OJ/lib/python3.11/site-packages/jishaku/cog.py", line 20, in <module>
    from jishaku.features.filesystem import FilesystemFeature
  File "/home/tilda/.local/share/virtualenvs/maho-RiUJz-OJ/lib/python3.11/site-packages/jishaku/features/filesystem.py", line 25, in <module>
    from jishaku.paginators import PaginatorInterface, WrappedFilePaginator, use_file_check
  File "/home/tilda/.local/share/virtualenvs/maho-RiUJz-OJ/lib/python3.11/site-packages/jishaku/paginators.py", line 26, in <module>
    from jishaku.shim.paginator_200 import PaginatorEmbedInterface, PaginatorInterface
  File "/home/tilda/.local/share/virtualenvs/maho-RiUJz-OJ/lib/python3.11/site-packages/jishaku/shim/paginator_200.py", line 29, in <module>
    a: MaybeButton[T],
       ~~~~~~~~~~~^^^
  File "/home/tilda/.pyenv/versions/3.11.0/lib/python3.11/typing.py", line 360, in inner
    return cached(*args, **kwds)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/home/tilda/.pyenv/versions/3.11.0/lib/python3.11/typing.py", line 1391, in __getitem__
    new_args = self._determine_new_args(args)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/tilda/.pyenv/versions/3.11.0/lib/python3.11/typing.py", line 1439, in _determine_new_args
    subargs.append(new_arg_by_param[x])
                   ~~~~~~~~~~~~~~~~^^^
KeyError: +ClientT

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/tilda/maho/bot.py", line 38, in <module>
    asyncio.run(setup_bot())
  File "/home/tilda/.pyenv/versions/3.11.0/lib/python3.11/asyncio/runners.py", line 190, in run
    return runner.run(main)
           ^^^^^^^^^^^^^^^^
  File "/home/tilda/.pyenv/versions/3.11.0/lib/python3.11/asyncio/runners.py", line 118, in run
    return self._loop.run_until_complete(task)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/tilda/.pyenv/versions/3.11.0/lib/python3.11/asyncio/base_events.py", line 650, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "/home/tilda/maho/bot.py", line 33, in setup_bot
    await bot.load_extension('jishaku')
  File "/home/tilda/.local/share/virtualenvs/maho-RiUJz-OJ/lib/python3.11/site-packages/discord/ext/commands/bot.py", line 1013, in load_extension
    await self._load_from_module_spec(spec, name)
  File "/home/tilda/.local/share/virtualenvs/maho-RiUJz-OJ/lib/python3.11/site-packages/discord/ext/commands/bot.py", line 938, in _load_from_module_spec
    raise errors.ExtensionFailed(key, e) from e
discord.ext.commands.errors.ExtensionFailed: Extension 'jishaku' raised an error: KeyError: +ClientT
Traceback (most recent call last):
  File "/home/tilda/.local/share/virtualenvs/maho-RiUJz-OJ/lib/python3.11/site-packages/logbook/handlers.py", line 238, in handle
    self.emit(record)
  File "/home/tilda/.local/share/virtualenvs/maho-RiUJz-OJ/lib/python3.11/site-packages/logbook/handlers.py", line 602, in emit
    msg = self.format(record)
          ^^^^^^^^^^^^^^^^^^^
  File "/home/tilda/.local/share/virtualenvs/maho-RiUJz-OJ/lib/python3.11/site-packages/logbook/handlers.py", line 217, in format
    return self.formatter(record, self)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/tilda/.local/share/virtualenvs/maho-RiUJz-OJ/lib/python3.11/site-packages/logbook/handlers.py", line 411, in __call__
    line = self.format_record(record, handler)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/tilda/.local/share/virtualenvs/maho-RiUJz-OJ/lib/python3.11/site-packages/logbook/handlers.py", line 395, in format_record
    return self._formatter.format(record=record, handler=handler)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ImportError: sys.meta_path is None, Python is likely shutting down
Logged from file /home/tilda/.pyenv/versions/3.11.0/lib/python3.11/asyncio/base_events.py, line 1757

Checklist

  • I have updated discord.py and jishaku to the latest available versions and have confirmed that this issue is still present
  • I have searched the open issues for duplicates
  • I have shown the entire traceback, if possible
  • I have removed my token from display, if visible

System information

discord.py 2.3.2

Jishaku v2.5.1

@tilda tilda changed the title KeyError on Python versions 3.11 KeyError on Python version 3.11.0 Oct 16, 2023
@scarletcafe
Copy link
Owner

Could you try a newer version of 3.11? It sounds like this is a Python bug more than a Jishaku bug. 3.12 iirc doesn't work on the PyPI version judging by #213 , but master should work and I plan to do a release soon-ish hopefully

@Soheab
Copy link

Soheab commented Oct 16, 2023

We found out (in the dpy server) that this is indeed a bug in Python 3.11.0 and was fixed in 3.11.1

From the changelogs:

gh-98852: Fix subscription of type aliases containing bare generic types or types like TypeVar: for example tuple[A, T][int] and tuple[TypeVar, T][int], where A is a generic type, and T is a type variable.

@tilda
Copy link
Author

tilda commented Oct 16, 2023

yeah, seems 3.11.0 in particular is the issue. my pyenv was outdated so it thought .0 was the latest - update of that and a compile of a newer 3.11 release seemed to fix the issue.

since it's not actually that much of an issue i suppose i'll close this up...

@tilda tilda closed this as not planned Won't fix, can't repro, duplicate, stale Oct 16, 2023
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