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

Change exec_module to load_module #2249

Merged
merged 2 commits into from Jul 12, 2020
Merged

Change exec_module to load_module #2249

merged 2 commits into from Jul 12, 2020

Conversation

alexhenrie
Copy link
Contributor

@alexhenrie alexhenrie commented Jul 11, 2020

I originally wrote this code using load_module and then changed it to exec_module because the documentation says that load_module is deprecated, but I didn't notice that exec_module requires an argument. Since it's not clear from the documentation how exec_module is supposed to be used, and load_module doesn't actually emit a DeprecationWarning (fixing the warning was the original motivation for changing this code), I think we should just use load_module for now.

@hugovk
Copy link
Contributor

hugovk commented Jul 11, 2020

Thanks for the quick update!

Is it possible to include tests for this code?

And do you have an idea why we only hit this on Python 3.9 and not 3.5-3.8?

@alexhenrie
Copy link
Contributor Author

alexhenrie commented Jul 11, 2020

@hugovk Unfortunately, I don't know the answer to either of those questions.

@jaraco jaraco merged commit 8b45da0 into pypa:master Jul 12, 2020
15 of 23 checks passed
@pangloss
Copy link

pangloss commented Jul 13, 2020

This issue hit me today on both 3.7.5 and 3.7.7.

@grlee77
Copy link

grlee77 commented Jul 14, 2020

Since it's not clear from the documentation how exec_module is supposed to be used, and load_module doesn't actually emit a DeprecationWarning (fixing the warning was the original motivation for changing this code), I think we should just use load_module for now.

By strange coincidence, I just happened to be looking at this same load_module vs exec_module usage for our setup.py in PyWavelets. I think in your case, the code would be something like the following (untested, adapated from an answer in this stack overflow post):

 import types
 from importlib.machinery import ExtensionFileLoader
 loader = ExtensionFileLoader(__name__, __file__)
 module = types.ModuleType(loader.name)
 loader.exec_module(module)

@danielgordon10
Copy link

danielgordon10 commented Jul 25, 2020

Can you please push a patch to PYPI? Many projects that don't pin the version are starting to get the bug.

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.

None yet

6 participants