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

DeprecationWarning: the load_module() method is deprecated and slated for removal in Python 3.12; use exec_module() instead #2576

Merged
merged 2 commits into from Feb 5, 2024

Conversation

mgor
Copy link
Contributor

@mgor mgor commented Feb 1, 2024

When running the unit tests and looking at the output, the DeprecationWarning in the title is thrown/visible a couple of times.

In python 3.4 load_module was replaced with exec_module. [0][1]

Deprecated since version 3.4: The recommended API for loading a module is exec_module() (and create_module()). Loaders should implement it instead of load_module(). The import machinery takes care of all the other responsibilities of load_module() when exec_module() is implemented.

The tests does indeed work on 3.12, so seems like it hasn't been removed yet,
but this PR replaces the call to load_module in locust.util.load_locustfile.load_locustfile to use exec_module instead.

[0] https://peps.python.org/pep-0451/
[1] https://docs.python.org/3/library/importlib.html#importlib.abc.Loader.load_module

instead of `load_module`, which is deprecated and was planned to be removed in 3.12.
@cyberw
Copy link
Collaborator

cyberw commented Feb 1, 2024

Awesome. I've been annoyed by this for a long time. Will sure to merge this once the modern-UI-default is released.

@cyberw cyberw merged commit ba189b1 into locustio:master Feb 5, 2024
15 checks passed
cyberw added a commit that referenced this pull request Feb 6, 2024
…odule during import, but it can be worked around (this used to work before #2576)
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

2 participants