MCPcopy Index your code
hub / github.com/python/cpython / extended_linecache_checkcache

Function extended_linecache_checkcache

Lib/idlelib/pyshell.py:100–117  ·  view source on GitHub ↗

Extend linecache.checkcache to preserve the entries Rather than repeating the linecache code, patch it to save the entries, call the original linecache.checkcache() (skipping them), and then restore the saved entries. orig_checkcache is bound at definiti

(filename=None,
                                  orig_checkcache=linecache.checkcache)

Source from the content-addressed store, hash-verified

98capture_warnings(True)
99
100def extended_linecache_checkcache(filename=None,
101 orig_checkcache=linecache.checkcache):
102 """Extend linecache.checkcache to preserve the <pyshell#...> entries
103
104 Rather than repeating the linecache code, patch it to save the
105 <pyshell#...> entries, call the original linecache.checkcache()
106 (skipping them), and then restore the saved entries.
107
108 orig_checkcache is bound at definition time to the original
109 method, allowing it to be patched.
110 """
111 cache = linecache.cache
112 save = {}
113 for key in list(cache):
114 if key[:1] + key[-1:] == '<>':
115 save[key] = cache.pop(key)
116 orig_checkcache(filename)
117 cache.update(save)
118
119# Patch linecache.checkcache():
120linecache.checkcache = extended_linecache_checkcache

Callers

nothing calls this directly

Calls 3

listClass · 0.85
popMethod · 0.45
updateMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…