pytest-dev / pytest-dev/pytest

imports of distutils pick up wrong parent module

Open
#12,490 7 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

topic: collection
Dominant language
Python
Stars
14.5k
Forks
3.4k
Avg merge
2d 9h
Merged PRs (30d)
35

Description

In pypa/distutils#259, I'm tracking down an emergent regression in the import logic that breaks the test suite on pytest 8.1 and 8.2.

It looks like it's successfully discovering distutils/cygwincompiler.py, but then when a relative import from there imports .version, it's getting $prefix/lib/distutils/version.py.

I haven't yet root caused it, and it may be related to https://github.com/pytest-dev/pytest/issues/12044 or other open issues.

I'll continue to investigate until I have a better reproducer.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the test-suite regression with pytest 8.1 and 8.2, then trace imports from distutils/cygwincompiler.py through the relative import of .version. Compare the discovered module with $prefix/lib/distutils/version.py and establish a smaller reproducer. Done means the intended distutils module is selected and the affected tests pass.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
testing-qa
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.