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

Define create_module()/exec_module() in VendorImporter #2517

Merged
merged 1 commit into from
Jan 16, 2021

Conversation

hroncok
Copy link
Contributor

@hroncok hroncok commented Dec 30, 2020

Summary of changes

Fixes #2481

Pull Request Checklist

@vstinner
Copy link
Contributor

vstinner commented Jan 4, 2021

The "Automated Tests / test (3.6, ubuntu-latest)" fails. I don't know if it's related to the PR.

XFAIL setuptools/tests/test_dist.py::test_read_metadata[Metadata Version 1.2: Project-Url-attrs6]
  Issue #1578: project_urls not read
XFAIL setuptools/tests/test_dist.py::test_read_metadata[Metadata Version 2.1: Provides Extra-attrs8]
  provides_extras not read
(...)
= 2 failed, 783 passed, 17 skipped, 5 xfailed, 1 xpassed in 212.12s (0:03:32) ==

I don't know pytest. I read that @pytest.mark.xfail marker indicates that a test is expected to fail. Does it mean that the two tests pass whereas they must fail?

@hroncok
Copy link
Contributor Author

hroncok commented Jan 4, 2021

XFAIL means they failed and were expected to fail.

@vstinner
Copy link
Contributor

vstinner commented Jan 4, 2021

Ah, I think that the two tests that failed are:

  • test_warns_deprecation: .../lib/python3.6/importlib/util.py:102: ValueError: name.__spec__ is None
  • test_deprecation_stderr :importlib.util.find_spec(packageName): ValueError. "WARNING: Testing via this command is deprecated and will be removed in a future version. Users looking for a generic test entry point independent of test runner are encouraged to use tox."

@hroncok hroncok force-pushed the load_module branch 2 times, most recently from 3f1b70e to 542d24b Compare January 4, 2021 12:36
@hroncok hroncok changed the title Use create_module()/exec_module() instead of load_module() where possible Define create_module()/exec_module() in VendorImporter Jan 4, 2021
@hroncok
Copy link
Contributor Author

hroncok commented Jan 4, 2021

I've removed the bits that I didn't understand. This should do.

@hroncok
Copy link
Contributor Author

hroncok commented Jan 4, 2021

In the current form, this fixes most of the failures in depending packages. Related #2493 remains unfixed (I had no idea how to fix it).

Copy link
Contributor

@vstinner vstinner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

I wrote a similar fix in the six module: benjaminp/six@e51553a

@hroncok hroncok marked this pull request as ready for review January 9, 2021 10:29
@hroncok
Copy link
Contributor Author

hroncok commented Jan 9, 2021

Together with #2523 this fixes the problems we saw in Fedora.

sqlalchemy-bot pushed a commit to sqlalchemy/mako that referenced this pull request Jan 14, 2021
Fixed Python deprecation issues related to module importing, as well as
file access within the Lingua plugin, for deprecated APIs that began to
emit warnings under Python 3.10.  Pull request courtesy Petr Viktorin.

This modernizes the code to avoid `DeprecationWarning` and `ResourceWarning` encountered in the test suite under Python 3.10a4:
- [load_module](https://docs.python.org/3/library/importlib.html#importlib.abc.Loader.load_module) is deprecated
- Some files weren't being closed

This changes the semantics of the `compat.load_module` function: on Python 3.5+, the module is no longer inserted in `sys.modules`. All non-test calls did `del sys.modules[self.module_id]` right after the call, anyway. On older Python, the module is inserted and then deleted.

(Some additional `DeprecationWarning` come from Setuptools: pypa/setuptools#2517)

Closes: #328
Pull-request: #328
Pull-request-sha: 87c1d09

Change-Id: I9cb3772f6812ef14297792344caf2f9aa5337adf
@jaraco jaraco merged commit 6ad2fb0 into pypa:main Jan 16, 2021
The-Compiler added a commit to qutebrowser/qutebrowser that referenced this pull request Apr 7, 2021
pypa/setuptools#2517
pypa/setuptools#2523
(something in tox/virtualenv probably uses an older setuptools...)

benjaminp/six#352 (not released yet)
@hroncok hroncok deleted the load_module branch April 8, 2021 08:27
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.

[Forward compatibility][BUG] pkg_resources.extern.VendorImporter lacks exec_module() method
3 participants