[Python-checkins] bpo-38792: Remove IDLE shell calltip before new prompt. (GH-17150)

Miss Islington (bot) webhook-mailer at python.org
Thu Jan 30 21:12:50 EST 2020


https://github.com/python/cpython/commit/8d021140866d050f90a4b44c2607f21be43208c1
commit: 8d021140866d050f90a4b44c2607f21be43208c1
branch: 3.7
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: GitHub <noreply at github.com>
date: 2020-01-30T18:12:46-08:00
summary:

bpo-38792: Remove IDLE shell calltip before new prompt. (GH-17150)


Previously, a calltip might be left after SyntaxError, KeyboardInterrupt, or Shell Restart.

Co-authored-by: Terry Jan Reedy <tjreedy at udel.edu>
Co-authored-by: Tal Einat <taleinat+github at gmail.com>
(cherry picked from commit bfdeaa37b3df7466624c17f9450d2bd1c3d95edf)

Co-authored-by: Zackery Spytz <zspytz at gmail.com>

files:
A Misc/NEWS.d/next/IDLE/2019-11-13-23-51-39.bpo-38792.xhTC5a.rst
M Lib/idlelib/NEWS.txt
M Lib/idlelib/calltip.py
M Lib/idlelib/editor.py
M Lib/idlelib/pyshell.py

diff --git a/Lib/idlelib/NEWS.txt b/Lib/idlelib/NEWS.txt
index 79534111bcd8e..2afbe82277ee9 100644
--- a/Lib/idlelib/NEWS.txt
+++ b/Lib/idlelib/NEWS.txt
@@ -3,6 +3,9 @@ Released on 2019-12-16?
 ======================================
 
 
+bpo-38792: Close a shell calltip if a :exc:`KeyboardInterrupt`
+or shell restart occurs.  Patch by Zackery Spytz.
+
 bpo-30780: Add remaining configdialog tests for buttons and
 highlights and keys tabs.
 
diff --git a/Lib/idlelib/calltip.py b/Lib/idlelib/calltip.py
index a3dda2678bd4d..2e0db60d476ae 100644
--- a/Lib/idlelib/calltip.py
+++ b/Lib/idlelib/calltip.py
@@ -33,7 +33,7 @@ def _make_tk_calltip_window(self):
         # See __init__ for usage
         return calltip_w.CalltipWindow(self.text)
 
-    def _remove_calltip_window(self, event=None):
+    def remove_calltip_window(self, event=None):
         if self.active_calltip:
             self.active_calltip.hidetip()
             self.active_calltip = None
@@ -55,7 +55,7 @@ def refresh_calltip_event(self, event):
             self.open_calltip(False)
 
     def open_calltip(self, evalfuncs):
-        self._remove_calltip_window()
+        self.remove_calltip_window()
 
         hp = HyperParser(self.editwin, "insert")
         sur_paren = hp.get_surrounding_brackets('(')
diff --git a/Lib/idlelib/editor.py b/Lib/idlelib/editor.py
index c9f1a1625ca5e..04c786dc5234c 100644
--- a/Lib/idlelib/editor.py
+++ b/Lib/idlelib/editor.py
@@ -328,7 +328,7 @@ def __init__(self, flist=None, filename=None, key=None, root=None):
         text.bind("<<run-module>>", scriptbinding.run_module_event)
         text.bind("<<run-custom>>", scriptbinding.run_custom_event)
         text.bind("<<do-rstrip>>", self.Rstrip(self).do_rstrip)
-        ctip = self.Calltip(self)
+        self.ctip = ctip = self.Calltip(self)
         text.bind("<<try-open-calltip>>", ctip.try_open_calltip_event)
         #refresh-calltip must come after paren-closed to work right
         text.bind("<<refresh-calltip>>", ctip.refresh_calltip_event)
diff --git a/Lib/idlelib/pyshell.py b/Lib/idlelib/pyshell.py
index 065122dec7a73..d5b310ffd7a9b 100755
--- a/Lib/idlelib/pyshell.py
+++ b/Lib/idlelib/pyshell.py
@@ -1292,6 +1292,7 @@ def resetoutput(self):
             self.text.insert("end-1c", "\n")
         self.text.mark_set("iomark", "end-1c")
         self.set_line_and_column()
+        self.ctip.remove_calltip_window()
 
     def write(self, s, tags=()):
         try:
diff --git a/Misc/NEWS.d/next/IDLE/2019-11-13-23-51-39.bpo-38792.xhTC5a.rst b/Misc/NEWS.d/next/IDLE/2019-11-13-23-51-39.bpo-38792.xhTC5a.rst
new file mode 100644
index 0000000000000..9aa2f0ffddfaf
--- /dev/null
+++ b/Misc/NEWS.d/next/IDLE/2019-11-13-23-51-39.bpo-38792.xhTC5a.rst
@@ -0,0 +1,2 @@
+Close an IDLE shell calltip if a :exc:`KeyboardInterrupt`
+or shell restart occurs.  Patch by Zackery Spytz.



More information about the Python-checkins mailing list