mirror of
https://github.com/python/cpython.git
synced 2025-10-09 16:34:44 +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
|
@ -24,6 +24,7 @@
|
|||
# governing permissions and limitations under the License.
|
||||
|
||||
|
||||
import importlib.machinery
|
||||
import sys
|
||||
import time
|
||||
import marshal
|
||||
|
@ -589,9 +590,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