From bfdeaa37b3df7466624c17f9450d2bd1c3d95edf Mon Sep 17 00:00:00 2001 From: Zackery Spytz Date: Thu, 30 Jan 2020 18:55:42 -0700 Subject: bpo-38792: Remove IDLE shell calltip before new prompt. (#17150) Previously, a calltip might be left after SyntaxError, KeyboardInterrupt, or Shell Restart. Co-authored-by: Terry Jan Reedy Co-authored-by: Tal Einat --- Lib/idlelib/NEWS.txt | 3 +++ Lib/idlelib/calltip.py | 4 ++-- Lib/idlelib/editor.py | 2 +- Lib/idlelib/pyshell.py | 1 + 4 files changed, 7 insertions(+), 3 deletions(-) (limited to 'Lib/idlelib') diff --git a/Lib/idlelib/NEWS.txt b/Lib/idlelib/NEWS.txt index 2b543985b3..d57ba7e6ba 100644 --- a/Lib/idlelib/NEWS.txt +++ b/Lib/idlelib/NEWS.txt @@ -3,6 +3,9 @@ Released on 2020-10-05? ====================================== +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 a3dda2678b..2e0db60d47 100644 --- a/Lib/idlelib/calltip.py +++ b/Lib/idlelib/calltip.py @@ -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('(') diff --git a/Lib/idlelib/editor.py b/Lib/idlelib/editor.py index c9f1a1625c..04c786dc52 100644 --- a/Lib/idlelib/editor.py +++ b/Lib/idlelib/editor.py @@ -328,7 +328,7 @@ class EditorWindow(object): text.bind("<>", scriptbinding.run_module_event) text.bind("<>", scriptbinding.run_custom_event) text.bind("<>", self.Rstrip(self).do_rstrip) - ctip = self.Calltip(self) + self.ctip = ctip = self.Calltip(self) text.bind("<>", ctip.try_open_calltip_event) #refresh-calltip must come after paren-closed to work right text.bind("<>", ctip.refresh_calltip_event) diff --git a/Lib/idlelib/pyshell.py b/Lib/idlelib/pyshell.py index 065122dec7..d5b310ffd7 100755 --- a/Lib/idlelib/pyshell.py +++ b/Lib/idlelib/pyshell.py @@ -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: -- cgit v1.2.1