GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — deepreload: don't reload standard-library modules (fixes #14292, closes #13331) by glaziermag · Pull Request #15402 · ipython/ipython

Conversation

@glaziermag

@glaziermag glaziermag commented Sep 23, 2026

Copy link
Copy Markdown

🤖🤖 Agent-written change (Claude Code), per CONTRIBUTING.md.

dreload(m) re-executes every module imported while its import hook is active, standard library included. Reloading os rebinds os.environ to an instance of a new os._Environ class, so IPython's own environ{...} printer, registered on the import-time type (pretty.py:853), stops matching. That is #14292. Reloading enum, re and the like duplicates their classes the same way.

This PR skips any module whose top-level name is in sys.stdlib_module_names, as #13331 suggested. Closes #13331, fixes #14292.

import os, sys, tempfile, pathlib
from IPython.lib.deepreload import reload as dreload
from IPython.lib.pretty import pretty

d = tempfile.mkdtemp(); sys.path.insert(0, d)
pathlib.Path(d, "m.py").write_text("import os\n")
import m
dreload(m)                       # main: prints "Reloading os", "Reloading abc", ...
print(pretty(os.environ)[:9])    # main: environ({    this branch: environ{'

The new test_deepreload_skips_stdlib covers os, enum and a stdlib submodule (json.decoder).

Related: the Linux/3.11 skips added in 8ec6f87 blame "an upstream matplotlib marker-style regression" and "an os.environ repr format difference". They match this mechanism. The 07-07 job failed test_pretty_environ with environ({...}) plus Unrecognized marker style 'None'. With the skips removed, a fork run in which a stdlib reload happens earlier in the session (the new test, run against main's deepreload.py) fails exactly those six tests with the same messages, plus the new test. On today's main they pass on Linux/3.11 with the skips removed (run, variant main), so the skips could be dropped. I can add that to this PR if you'd like.

🤖 Generated with Claude Code

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@glaziermag @claude
deepreload: never reload standard-library modules 🤖🤖
991239b
dreload() re-executed any stdlib module imported while its import hook
was active (os, enum, re, codecs, ...), replacing os.environ with an
instance of a new os._Environ class and enum.Enum with a new class.

Closes ipython#13331, fixes ipython#14292.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

test_deepreload breaks test_pretty_environ with Python 3.12 Maybe use sys.stdlib_module_names for deepreload.

Uh oh!

There was an error while loading. Please reload this page.

1 participant

@glaziermag
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.