14
14
# The cache. Maps filenames to either a thunk which will provide source code,
15
15
# or a tuple (size, mtime, lines, fullname) once loaded.
16
16
cache = {}
17
+ _interactive_cache = {}
17
18
18
19
19
20
def clearcache ():
@@ -35,10 +36,12 @@ def getlines(filename, module_globals=None):
35
36
"""Get the lines for a Python source file from the cache.
36
37
Update the cache if it doesn't contain an entry for this file already."""
37
38
38
- if filename in cache :
39
- entry = cache [filename ]
40
- if len (entry ) != 1 :
41
- return cache [filename ][2 ]
39
+ for the_cache in (cache , _interactive_cache ):
40
+ print (the_cache )
41
+ if filename in the_cache :
42
+ entry = the_cache [filename ]
43
+ if len (entry ) != 1 :
44
+ return the_cache [filename ][2 ]
42
45
43
46
try :
44
47
return updatecache (filename , module_globals )
@@ -159,11 +162,13 @@ def lazycache(filename, module_globals):
159
162
get_source method must be found, the filename must be a cacheable
160
163
filename, and the filename must not be already cached.
161
164
"""
162
- if filename in cache :
163
- if len (cache [filename ]) == 1 :
164
- return True
165
- else :
166
- return False
165
+ for the_cache in (cache , _interactive_cache ):
166
+ print (the_cache )
167
+ if filename in the_cache :
168
+ if len (the_cache [filename ]) == 1 :
169
+ return True
170
+ else :
171
+ return False
167
172
if not filename or (filename .startswith ('<' ) and filename .endswith ('>' )):
168
173
return False
169
174
# Try for a __loader__, if available
@@ -183,8 +188,8 @@ def get_lines(name=name, *args, **kwargs):
183
188
return False
184
189
185
190
186
- def _register_code (code , string , name ):
187
- cache [ code ] = (
191
+ def _register_code (code , filename , string , name ):
192
+ _interactive_cache [ filename ] = (
188
193
len (string ),
189
194
None ,
190
195
[line + '\n ' for line in string .splitlines ()],
0 commit comments