Skip to content

Avoid importing submodules sharing names with standard library modules#2702

Merged
jacobtylerwalls merged 1 commit intomainfrom
jtw/avoid-import
Mar 9, 2025
Merged

Avoid importing submodules sharing names with standard library modules#2702
jacobtylerwalls merged 1 commit intomainfrom
jtw/avoid-import

Conversation

@jacobtylerwalls
Copy link
Member

@jacobtylerwalls jacobtylerwalls commented Mar 9, 2025

Type of Changes

Type
🐛 Bug fix

Description

Closes #2684
Avoid importing user_module.std_lib_name if we can help it.

sys.path.insert(0, resources.find("data"))
try:
with pytest.raises(ImportError):
spec._find_spec_with_path(
Copy link
Member Author

Choose a reason for hiding this comment

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

I would have preferred to find a public interface to test, but after almost an hour of fiddling I threw in the towel.

@jacobtylerwalls jacobtylerwalls merged commit 9f8faeb into main Mar 9, 2025
19 of 20 checks passed
@jacobtylerwalls jacobtylerwalls deleted the jtw/avoid-import branch March 9, 2025 20:49
github-actions bot pushed a commit that referenced this pull request Mar 9, 2025
Pierre-Sassoulas pushed a commit that referenced this pull request Mar 9, 2025
#2702) (#2703)

(cherry picked from commit 9f8faeb)

Co-authored-by: Jacob Walls <jacobtylerwalls@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Astroid >=3.3.7 imports and executes modules that contain any similarly named identifier as some stdlib module

3 participants