that name.
"""
-import sys
-import os
-
__all__ = ["getline", "clearcache", "checkcache", "lazycache"]
size, mtime, lines, fullname = entry
if mtime is None:
continue # no-op for files loaded via a __loader__
+ try:
+ # This import can fail if the interpreter is shutting down
+ import os
+ except ImportError:
+ return
try:
stat = os.stat(fullname)
except OSError:
def updatecache(filename, module_globals=None):
+ # These imports are not at top level because linecache is in the critical
+ # path of the interpreter startup and importing os and sys take a lot of time
+ # and slow down the startup sequence.
+ import os
+ import sys
+
"""Update a cache entry and return its list of lines.
If something's wrong, print a message, discard the cache entry,
and return an empty list."""