summaryrefslogtreecommitdiffstats
path: root/Lib/idlelib/pyshell.py
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2023-10-18 08:40:39 (GMT)
committerGitHub <noreply@github.com>2023-10-18 08:40:39 (GMT)
commit7c308f4c64dca4093b70b7a5e49f81c4f3679359 (patch)
tree80ab9d59668b1dbd46468f0b09494b9ef0906d76 /Lib/idlelib/pyshell.py
parent50d936a125b17ff31b527347c0f4c37aa85efb83 (diff)
downloadcpython-7c308f4c64dca4093b70b7a5e49f81c4f3679359.zip
cpython-7c308f4c64dca4093b70b7a5e49f81c4f3679359.tar.gz
cpython-7c308f4c64dca4093b70b7a5e49f81c4f3679359.tar.bz2
[3.11] gh-103737: IDLE - Remove unneeded .keys() for dict iteration (GH-110960) (#111027)
gh-103737: IDLE - Remove unneeded .keys() for dict iteration (GH-110960) Add comments where .keys() is needed. Leave debugger usages along because situation is unclear as indicated in expanded comment. Most testing is manual. (cherry picked from commit baefbb21d91db2d950706737a6ebee9b2eff5c2d) Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
Diffstat (limited to 'Lib/idlelib/pyshell.py')
-rwxr-xr-xLib/idlelib/pyshell.py7
1 files changed, 4 insertions, 3 deletions
diff --git a/Lib/idlelib/pyshell.py b/Lib/idlelib/pyshell.py
index 3141b47..0a7ee59 100755
--- a/Lib/idlelib/pyshell.py
+++ b/Lib/idlelib/pyshell.py
@@ -747,10 +747,11 @@ class ModifiedInterpreter(InteractiveInterpreter):
self.tkconsole.open_stack_viewer()
def checklinecache(self):
- c = linecache.cache
- for key in list(c.keys()):
+ "Remove keys other than '<pyshell#n>'."
+ cache = linecache.cache
+ for key in list(cache): # Iterate list because mutate cache.
if key[:1] + key[-1:] != "<>":
- del c[key]
+ del cache[key]
def runcommand(self, code):
"Run the code without invoking the debugger"