File tree Expand file tree Collapse file tree 1 file changed +11
-3
lines changed Expand file tree Collapse file tree 1 file changed +11
-3
lines changed Original file line number Diff line number Diff line change 55that name.
66"""
77
8- import sys
9- import os
10-
118__all__ = ["getline" , "clearcache" , "checkcache" , "lazycache" ]
129
1310
@@ -66,6 +63,11 @@ def checkcache(filename=None):
6663 size , mtime , lines , fullname = entry
6764 if mtime is None :
6865 continue # no-op for files loaded via a __loader__
66+ try :
67+ # This import can fail if the interpreter is shutting down
68+ import os
69+ except ImportError :
70+ return
6971 try :
7072 stat = os .stat (fullname )
7173 except OSError :
@@ -76,6 +78,12 @@ def checkcache(filename=None):
7678
7779
7880def updatecache (filename , module_globals = None ):
81+ # These imports are not at top level because linecache is in the critical
82+ # path of the interpreter startup and importing os and sys take a lot of time
83+ # and slow down the startup sequence.
84+ import os
85+ import sys
86+
7987 """Update a cache entry and return its list of lines.
8088 If something's wrong, print a message, discard the cache entry,
8189 and return an empty list."""
You can’t perform that action at this time.
0 commit comments