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

fix: hooks not loading on python 3.13 #759

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

sudoAlphaX
Copy link

@sudoAlphaX sudoAlphaX commented Feb 22, 2025

Hooks refuse to load on python version 3.13 because of the error
AttributeError: 'FileFinder' object has no attribute 'find_module'

This patch changes find_module to find_spec to fix this issue. I have
tested it using python version 3.8 and 3.13.

Here is the full trace before this patch:

Engine: Reading config files...
Data: Initializing...
libanilist: Initializing...
Data: Using libanilist (anime)
Engine: Parsing redirection file...
Engine: Scanning local library...
Engine: Importing user hooks...
Traceback (most recent call last):
  File "/usr/bin/trackma", line 8, in <module>
    sys.exit(main())
             ~~~~^^
  File "/usr/lib/python3.13/site-packages/trackma/ui/cli.py", line 1071, in main
    main_cmd.start()
    ~~~~~~~~~~~~~~^^
  File "/usr/lib/python3.13/site-packages/trackma/ui/cli.py", line 180, in start
    self.engine.start()
    ~~~~~~~~~~~~~~~~~^^
  File "/usr/lib/python3.13/site-packages/trackma/engine.py", line 305, in start
    module = loader.find_module(name).load_module(name)
             ^^^^^^^^^^^^^^^^^^
AttributeError: 'FileFinder' object has no attribute 'find_module'

Fixes #736.
Duplicates and closes #746.

Hooks refuse to load on python version 3.13 because of the error
`AttributeError: 'FileFinder' object has no attribute 'find_module'`

This patch changes find_module to importlib.import_module() to fix this issue. I have
tested it using python version 3.8 and 3.13.

Here is the full trace before this patch:

```py
Engine: Reading config files...
Data: Initializing...
libanilist: Initializing...
Data: Using libanilist (anime)
Engine: Parsing redirection file...
Engine: Scanning local library...
Engine: Importing user hooks...
Traceback (most recent call last):
  File "/usr/bin/trackma", line 8, in <module>
    sys.exit(main())
             ~~~~^^
  File "/usr/lib/python3.13/site-packages/trackma/ui/cli.py", line 1071, in main
    main_cmd.start()
    ~~~~~~~~~~~~~~^^
  File "/usr/lib/python3.13/site-packages/trackma/ui/cli.py", line 180, in start
    self.engine.start()
    ~~~~~~~~~~~~~~~~~^^
  File "/usr/lib/python3.13/site-packages/trackma/engine.py", line 305, in start
    module = loader.find_module(name).load_module(name)
             ^^^^^^^^^^^^^^^^^^
AttributeError: 'FileFinder' object has no attribute 'find_module'

```

Co-Authored-By: FichteFoll <[email protected]>
@sudoAlphaX
Copy link
Author

@FichteFoll something like this would do?

@sudoAlphaX sudoAlphaX marked this pull request as ready for review February 24, 2025 14:42
@FichteFoll
Copy link
Collaborator

I'll have to look into this in more detail to evaluate whether it is worth abandoning the loader we get from pkgutil already.

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

Successfully merging this pull request may close these issues.

'FileFinder' object has no attribute 'find_module'
2 participants