python / python/cpython

Reloading a lazy module that has not yet been materailized should be no-op

Open
#139,686 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Bug report

Bug description:

Reloading a not-yet materialized lazy module is not supported well. It makes sense for the reloading in this case to be no-op since when the actual loading happens e.g. by accessing an attribute, the new code will be loaded anyway. Currently, the reload tries to reload the module while its loaded is lazy in the first place.

CPython versions tested on:

3.13, 3.12, 3.14, CPython main branch

Operating systems tested on:

Linux

Linked PRs
  • gh-139857
  • gh-142649
  • gh-143584

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

Review the linked PRs gh-139857, gh-142649, and gh-143584 first, since they show the work already proposed for this behavior. Trace the reload path for a lazy module and verify that reloading before materialization is a no-op while later attribute access still loads the updated code; completion should include regression coverage.

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
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.