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

importlib.machinery error with create_api #87

Closed
bulletmark opened this issue Dec 6, 2023 · 6 comments
Closed

importlib.machinery error with create_api #87

bulletmark opened this issue Dec 6, 2023 · 6 comments
Labels
bug Something isn't working

Comments

@bulletmark
Copy link

This is essentially same issue as issue #85. I get the following error:

$ venv/bin/python ./p05
Traceback (most recent call last):
  File "/home/mark/Data/comps/aoc/2023/./p05", line 8, in <module>
    P = portion.create_api(IntInterval)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/mark/Data/comps/aoc/2023/venv/lib/python3.12/site-packages/portion/api.py", line 66, in create_api
    importlib.machinery.ModuleSpec(module_name, None)
    ^^^^^^^^^^^^^^^^^^^
AttributeError: module 'importlib' has no attribute 'machinery'

This is using portion 2.4.1 and happens on Python versions 3.10, 3.11, 3.12 but it does not happen with Python 3.9 where it works fine.

The fix for #85 was to add import importlib.util. I find here that adding import importlib.machinery fixes this issue.

@AlexandreDecan AlexandreDecan added the bug Something isn't working label Dec 6, 2023
@AlexandreDecan
Copy link
Owner

Thanks for reporting this issue! I'll have a look at it soon :-)

@AlexandreDecan
Copy link
Owner

For "posterity": more information about why this bug happens https://discuss.python.org/t/python3-11-importlib-no-longer-exposes-util/25641/21

I'm going to release a hot fix for this today (portion 2.4.2). In the meantime, you can import importlib.machinery in your own code before calling creating_api ;-)

@bulletmark
Copy link
Author

@AlexandreDecan can you please add the discussions tab to this repo?

@AlexandreDecan
Copy link
Owner

AlexandreDecan commented Dec 6, 2023 via email

@bulletmark
Copy link
Author

I would like to discuss something completely unrelated to this present issue but certainly not worthy of an issue. Discussions are "lightweight issues" which encourage more liberal dialog and wider participation.

@AlexandreDecan
Copy link
Owner

Thanks!

I looked at how GitHub sells "Discussions" and, to be honest, I'm not really convinced :-) I prefer not to multiply the communication channels for this repository, for simplicity and personal preference ;-)

If you don't mind, please open an issue (and I'll add the "discussion" label on it) or, if you prefer, you can contact me by e-mail (but I usually consider that discussions/questions/etc. should be "public" if they can benefit to other people as well :-) Perhaps I'll change my mind and I'll convert the issue to a "discussion thread" afterwards :-p

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants