Skip to content

Fix plugin loading for Python 3.13 #83

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

Merged
merged 2 commits into from
Jan 2, 2025

Conversation

wfraser
Copy link
Contributor

@wfraser wfraser commented Dec 30, 2024

DOOL VERSION

Dool 1.3.2

Python 3.13.1 (main, Dec 4 2024, 18:05:56) [GCC 14.2.1 20240910]

Arch Linux

SUMMARY

Python 3.13 changes how the exec builtin works. See python/cpython#118888

Tl;dr: things defined in the exec context no longer show up in the caller's local scope; you have to explicitly pass a dict you want to be modified instead.

Before:

% dool --thermal
Traceback (most recent call last):
  File "/usr/bin/dool", line 2716, in main
    exec('global plug; plug = dool_plugin(); del(dool_plugin)')
    ~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<string>", line 1, in <module>
NameError: name 'dool_plugin' is not defined. Did you mean: 'show_plugins'?

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/bin/dool", line 3057, in <module>
    __main()
    ~~~~~~^^
  File "/usr/bin/dool", line 3045, in __main
    main()
    ~~~~^^
  File "/usr/bin/dool", line 2726, in main
    if mod == mods[-1]:
       ^^^
NameError: name 'mod' is not defined

After:

% dool --thermal
the
tz0
 30
 30
 30
...

@scottchiefbaker
Copy link
Owner

Can you change this to target the next branch?

@wfraser
Copy link
Contributor Author

wfraser commented Dec 31, 2024

Ah, didn't know about that branch. Rebased.

@wfraser wfraser changed the base branch from master to next December 31, 2024 20:40
@scottchiefbaker
Copy link
Owner

This looks good to me. I'm going to track down a system with Python 3.13 on it to test and I'll get back to you.

@scottchiefbaker
Copy link
Owner

Will this change/break anything for older versions of Python?

@wfraser
Copy link
Contributor Author

wfraser commented Dec 31, 2024

I tried as far back as Python 3.8 and everything worked fine

@raylu
Copy link
Contributor

raylu commented Dec 31, 2024

track down a system with Python 3.13 on it to test

can usually just docker run --rm -it python:3.13

@scottchiefbaker
Copy link
Owner

Looking at this it looks fine... and honestly a little cleaner than what we're doing now so it's a win-win. I'm fine landing this and letting more people test.

For organization purposes can you back-out the drive-by mod fix and put that in a different PR and I'll land that separately?

@scottchiefbaker
Copy link
Owner

scottchiefbaker commented Jan 2, 2025

This looks fantastic, thanks for writing this up.

I wish all the bug reports and fixes I receive were as well researched and presented as this. Makes my job much easier. Gold star for you.

@wfraser
Copy link
Contributor Author

wfraser commented Jan 2, 2025

Thanks for maintaining this lovely tool!

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.

3 participants