python / python/cpython

Set loader for namespace packages in `PathFinder.find_spec`

Open
#92,205 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

topic-importlib type-bug
Dominant language
Python
Stars
77.2k
Forks
36k
PR merge metrics
PR metrics pending

Description

Bug report

While fixing #84530, I ran into the issue of the loader sometimes not being set for namespace packages. After talking with @ericvsmith, it seems that might have just been overlooked.

Responsible code:
https://github.com/python/cpython/blob/ebb8b512e959ca1a0a506ac0f0faf461b1b2ff85/Lib/importlib/_bootstrap_external.py#L1511

Your environment

  • CPython versions tested on: main
  • Operating system and architecture:

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

Read Lib/importlib/_bootstrap_external.py at the PathFinder.find_spec code linked in the issue, then review issue #84530 for the related context. Reproduce or inspect namespace-package discovery on CPython main and verify that the resulting spec consistently includes the expected loader.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.