]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-38792: Remove IDLE shell calltip before new prompt. (GH-17150)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Fri, 31 Jan 2020 02:12:46 +0000 (18:12 -0800)
committerGitHub <noreply@github.com>
Fri, 31 Jan 2020 02:12:46 +0000 (18:12 -0800)
Previously, a calltip might be left after SyntaxError, KeyboardInterrupt, or Shell Restart.

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

Co-authored-by: Zackery Spytz <zspytz@gmail.com>
Lib/idlelib/NEWS.txt
Lib/idlelib/calltip.py
Lib/idlelib/editor.py
Lib/idlelib/pyshell.py
Misc/NEWS.d/next/IDLE/2019-11-13-23-51-39.bpo-38792.xhTC5a.rst [new file with mode: 0644]

index 79534111bcd8e052df769e2ccc08dced61df850b..2afbe82277ee9f36883a29ee4d0dd799c91dab66 100644 (file)
@@ -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.
 
index a3dda2678bd4da48220757196c15694d5066f47a..2e0db60d476aefa0de7ba5720af3c5e9aeac947a 100644 (file)
@@ -33,7 +33,7 @@ class Calltip:
         # 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 @@ class Calltip:
             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('(')
index c9f1a1625ca5ea18823ce7ab1a62364b7ec1af1f..04c786dc5234c2478a4f5a377210afb6e9f8496a 100644 (file)
@@ -328,7 +328,7 @@ class EditorWindow(object):
         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)
index 065122dec7a73d435b7d4a01217d47789c50e96a..d5b310ffd7a9be769c62d310d50527cfff38e3d8 100755 (executable)
@@ -1292,6 +1292,7 @@ class PyShell(OutputWindow):
             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 (file)
index 0000000..9aa2f0f
--- /dev/null
@@ -0,0 +1,2 @@
+Close an IDLE shell calltip if a :exc:`KeyboardInterrupt`
+or shell restart occurs.  Patch by Zackery Spytz.