deepreload: don't reload standard-library modules (fixes #14292, closes #13331) - #15402
Open
glaziermag wants to merge 1 commit into
Open
glaziermag wants to merge 1 commit into
glaziermag wants to merge 1 commit into
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
🤖🤖 Agent-written change (Claude Code), per CONTRIBUTING.md.
dreload(m)re-executes every module imported while its import hook is active, standard library included. Reloadingosrebindsos.environto an instance of a newos._Environclass, so IPython's ownenviron{...}printer, registered on the import-time type (pretty.py:853), stops matching. That is #14292. Reloadingenum,reand 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.The new
test_deepreload_skips_stdlibcoversos,enumand 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_environwithenviron({...})plusUnrecognized 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'sdeepreload.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, variantmain), so the skips could be dropped. I can add that to this PR if you'd like.🤖 Generated with Claude Code