Skip to content

Commit

Permalink
fix: hooks not loading on python 3.13
Browse files Browse the repository at this point in the history
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:

```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'
```
  • Loading branch information
sudoAlphaX committed Feb 22, 2025
1 parent a3c405f commit eff88ab
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion trackma/engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ def start(self):
# for later calls.
try:
self.msg.debug("Importing hook {}...".format(name))
module = loader.find_module(name).load_module(name)
module = loader.find_spec(name).loader.load_module(name)
if hasattr(module, 'init'):
module.init(self)
self.hooks_available.append(module)
Expand Down

0 comments on commit eff88ab

Please sign in to comment.