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

Fix namespace package detection for frozen stdlib modules on PyPy #1757

Merged
merged 3 commits into from
Aug 27, 2022

Conversation

jacobtylerwalls
Copy link
Member

Description

PyPy doesn't bother to set __spec__ on some frozen stdlib modules like importlib._bootstrap. We were using the lack of __spec__ as a heuristic for old-style namespace packages with pkg_resources. That assumption breaks given PyPy's behavior.

Type of Changes

Type
🐛 Bug fix

Related Issue

Fixes #1755

@coveralls
Copy link

coveralls commented Aug 27, 2022

Pull Request Test Coverage Report for Build 2940401201

  • 2 of 2 (100.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.0007%) to 92.347%

Totals Coverage Status
Change from base Build 2925757434: 0.0007%
Covered Lines: 9714
Relevant Lines: 10519

💛 - Coveralls

Copy link
Member

@Pierre-Sassoulas Pierre-Sassoulas left a comment

Choose a reason for hiding this comment

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

LGTM but I don't have pypy installed, let's wait for the reporter to confirm it works.

@emcd
Copy link

emcd commented Aug 27, 2022

@jacobtylerwalls : It works both against the minimal reproducer and the use case that originally triggered the issue. Thank you!

@jacobtylerwalls jacobtylerwalls merged commit 4c3bf08 into pylint-dev:main Aug 27, 2022
@jacobtylerwalls jacobtylerwalls deleted the pypy-importlib branch August 27, 2022 20:51
@DanielNoord
Copy link
Collaborator

Note to self: I actually opened an issue against PyPy for this. I'll open a PR to add some reference to this as I think it would be good to link it.

Also, shouldn't we try to infer namespaces better on PyPy? Instead of just giving up?

@jacobtylerwalls
Copy link
Member Author

I actually opened an issue against PyPy for this.

Thank you!

Also, shouldn't we try to infer namespaces better on PyPy? Instead of just giving up?

Only old-style pkg_resources namespace packages were affected, so I wasn't very concerned. We ought to quickly backport a crash fix, was my thinking.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Astroid 2.12.4 broken on PyPy 3.8 when importlib.import_module is used.
5 participants