mirror of
https://github.com/python/cpython.git
synced 2025-12-08 06:10:17 +00:00
GH-65961: Stop setting __cached__ on modules
This commit is contained in:
parent
e32c975640
commit
28f1334f1a
32 changed files with 93 additions and 240 deletions
|
|
@ -583,8 +583,7 @@ class ModuleSpec:
|
|||
`has_location` indicates that a spec's "origin" reflects a location.
|
||||
When this is True, `__file__` attribute of the module is set.
|
||||
|
||||
`cached` is the location of the cached bytecode file, if any. It
|
||||
corresponds to the `__cached__` attribute.
|
||||
`cached` is the location of the cached bytecode file, if any.
|
||||
|
||||
`submodule_search_locations` is the sequence of path entries to
|
||||
search when importing submodules. If set, is_package should be
|
||||
|
|
@ -717,10 +716,6 @@ def _spec_from_module(module, loader=None, origin=None):
|
|||
origin = getattr(loader, '_ORIGIN', None)
|
||||
if not origin and location is not None:
|
||||
origin = location
|
||||
try:
|
||||
cached = module.__cached__
|
||||
except AttributeError:
|
||||
cached = None
|
||||
try:
|
||||
submodule_search_locations = list(module.__path__)
|
||||
except AttributeError:
|
||||
|
|
@ -728,7 +723,7 @@ def _spec_from_module(module, loader=None, origin=None):
|
|||
|
||||
spec = ModuleSpec(name, loader, origin=origin)
|
||||
spec._set_fileattr = False if location is None else (origin == location)
|
||||
spec.cached = cached
|
||||
spec.cached = None
|
||||
spec.submodule_search_locations = submodule_search_locations
|
||||
return spec
|
||||
|
||||
|
|
@ -789,7 +784,7 @@ def _init_module_attrs(spec, module, *, override=False):
|
|||
module.__path__ = spec.submodule_search_locations
|
||||
except AttributeError:
|
||||
pass
|
||||
# __file__/__cached__
|
||||
# __file__
|
||||
if spec.has_location:
|
||||
if override or getattr(module, '__file__', None) is None:
|
||||
try:
|
||||
|
|
@ -797,12 +792,6 @@ def _init_module_attrs(spec, module, *, override=False):
|
|||
except AttributeError:
|
||||
pass
|
||||
|
||||
if override or getattr(module, '__cached__', None) is None:
|
||||
if spec.cached is not None:
|
||||
try:
|
||||
module.__cached__ = spec.cached
|
||||
except AttributeError:
|
||||
pass
|
||||
return module
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue