-
-
Notifications
You must be signed in to change notification settings - Fork 33.2k
Closed as not planned
Labels
stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytopic-importlibtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Description
Bug report
Bug description:
This may not be a bug, but it's a weirdness.
Why is there an automatic implicit re-registration of the builtins module in the latter case?
import sys
import importlib.util
import email
name = "email"
spec = importlib.util.find_spec(name)
sys.modules[name] = "ha"
print(sys.modules[name]) # ha
importlib.util.module_from_spec(spec)
print(sys.modules[name]) # ha
import builtins
name = "builtins"
spec = importlib.util.find_spec(name)
sys.modules[name] = "ha"
print(sys.modules[name]) # ha
importlib.util.module_from_spec(spec)
print(sys.modules[name]) # <module 'builtins' (built-in)>
CPython versions tested on:
3.12, 3.13
Operating systems tested on:
No response
Metadata
Metadata
Assignees
Labels
stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytopic-importlibtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error