diff options
author | Kurt B. Kaiser <kbk@shore.net> | 2002-11-29 22:10:53 (GMT) |
---|---|---|
committer | Kurt B. Kaiser <kbk@shore.net> | 2002-11-29 22:10:53 (GMT) |
commit | 818855939ac016492cb59d1fc2fea94cc0764855 (patch) | |
tree | 3b2cf4ced08c406962906b6d1d32361f63a48c2c /Lib/idlelib/PyShell.py | |
parent | 24884f76c6b59aa9cd716174907a02d5d172c2fc (diff) | |
download | cpython-818855939ac016492cb59d1fc2fea94cc0764855.zip cpython-818855939ac016492cb59d1fc2fea94cc0764855.tar.gz cpython-818855939ac016492cb59d1fc2fea94cc0764855.tar.bz2 |
Correct an error introduced at Rev 1.30. The keyword arg is necessary
to freeze the value of orig_checkcache. Otherwise infinite recursion.
Diffstat (limited to 'Lib/idlelib/PyShell.py')
-rw-r--r-- | Lib/idlelib/PyShell.py | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/Lib/idlelib/PyShell.py b/Lib/idlelib/PyShell.py index ffd8767..ad8263d 100644 --- a/Lib/idlelib/PyShell.py +++ b/Lib/idlelib/PyShell.py @@ -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): |