mirror of
https://github.com/python/cpython.git
synced 2025-07-07 19:35:27 +00:00
gh-65961: Do not rely solely on __cached__
(GH-97990)
Make sure `__spec__.cached` (at minimum) can be used.
This commit is contained in:
parent
f8edc6ff53
commit
e1c4d56fdd
11 changed files with 130 additions and 35 deletions
|
@ -7,6 +7,7 @@
|
|||
__all__ = ["run", "runctx", "Profile"]
|
||||
|
||||
import _lsprof
|
||||
import importlib.machinery
|
||||
import profile as _pyprofile
|
||||
|
||||
# ____________________________________________________________
|
||||
|
@ -169,9 +170,12 @@ def main():
|
|||
sys.path.insert(0, os.path.dirname(progname))
|
||||
with open(progname, 'rb') as fp:
|
||||
code = compile(fp.read(), progname, 'exec')
|
||||
spec = importlib.machinery.ModuleSpec(name='__main__', loader=None,
|
||||
origin=progname)
|
||||
globs = {
|
||||
'__file__': progname,
|
||||
'__name__': '__main__',
|
||||
'__spec__': spec,
|
||||
'__file__': spec.origin,
|
||||
'__name__': spec.name,
|
||||
'__package__': None,
|
||||
'__cached__': None,
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue