]> granicus.if.org Git - python/commitdiff
Correct an error introduced at Rev 1.30. The keyword arg is necessary
authorKurt B. Kaiser <kbk@shore.net>
Fri, 29 Nov 2002 22:10:53 +0000 (22:10 +0000)
committerKurt B. Kaiser <kbk@shore.net>
Fri, 29 Nov 2002 22:10:53 +0000 (22:10 +0000)
to freeze the value of orig_checkcache.  Otherwise infinite recursion.

Lib/idlelib/PyShell.py

index ffd8767fb5657922aade32bc0dd8b04d52dc122c..ad8263d68183ca7e299e5521a9795c7410aa6ac4 100644 (file)
@@ -45,15 +45,16 @@ else:
         file.write(warnings.formatwarning(message, category, filename, lineno))
     warnings.showwarning = idle_showwarning
 
-def linecache_checkcache():
+def extended_linecache_checkcache(orig_checkcache=linecache.checkcache):
     """Extend linecache.checkcache to preserve the <pyshell#...> entries
 
-    Rather than repeating the linecache code, patch it by saving the pyshell#
-    entries, call linecache.checkcache(), and then restore the saved
-    entries.
+    Rather than repeating the linecache code, patch it to save the pyshell#
+    entries, call the original linecache.checkcache(), and then restore the
+    saved entries.  Assigning the orig_checkcache keyword arg freezes its value
+    at definition time to the (original) method linecache.checkcache(), i.e.
+    makes orig_checkcache lexical.
 
     """
-    orig_checkcache=linecache.checkcache
     cache = linecache.cache
     save = {}
     for filename in cache.keys():
@@ -62,7 +63,8 @@ def linecache_checkcache():
     orig_checkcache()
     cache.update(save)
     
-linecache.checkcache = linecache_checkcache
+# Patch linecache.checkcache():
+linecache.checkcache = extended_linecache_checkcache
 
 
 class PyShellEditorWindow(EditorWindow):