From 152d306158a33f80bb16db2adf27f83dc31b4c72 Mon Sep 17 00:00:00 2001 From: Zackery Spytz Date: Thu, 14 Nov 2019 23:41:43 -0700 Subject: [PATCH] bpo-23544: IDLE hangs when selecting Stack Viewer with debug active "Stack Viewer" is now disabled when user code is running. --- Lib/idlelib/editor.py | 4 +++- Lib/idlelib/pyshell.py | 4 ++++ .../NEWS.d/next/IDLE/2019-11-14-23-41-07.bpo-23544.3etemb.rst | 2 ++ 3 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 Misc/NEWS.d/next/IDLE/2019-11-14-23-41-07.bpo-23544.3etemb.rst diff --git a/Lib/idlelib/editor.py b/Lib/idlelib/editor.py index dff104ff0f1..cba34bf8f6b 100644 --- a/Lib/idlelib/editor.py +++ b/Lib/idlelib/editor.py @@ -449,7 +449,9 @@ class EditorWindow(object): self.menudict = menudict = {} for name, label in self.menu_specs: underline, label = prepstr(label) - menudict[name] = menu = Menu(mbar, name=name, tearoff=0) + postcommand = getattr(self, f'{name}_menu_postcommand', None) + menudict[name] = menu = Menu(mbar, name=name, tearoff=0, + postcommand=postcommand) mbar.add_cascade(label=label, menu=menu, underline=underline) if macosx.isCarbonTk(): # Insert the application menu diff --git a/Lib/idlelib/pyshell.py b/Lib/idlelib/pyshell.py index 065122dec7a..d8d67e7d9bf 100755 --- a/Lib/idlelib/pyshell.py +++ b/Lib/idlelib/pyshell.py @@ -990,6 +990,10 @@ class PyShell(OutputWindow): self.showprompt() self.set_debugger_indicator() + def debug_menu_postcommand(self): + state = 'disabled' if self.executing else 'normal' + self.update_menu_state('debug', '*Stack Viewer', state) + def beginexecuting(self): "Helper for ModifiedInterpreter" self.resetoutput() diff --git a/Misc/NEWS.d/next/IDLE/2019-11-14-23-41-07.bpo-23544.3etemb.rst b/Misc/NEWS.d/next/IDLE/2019-11-14-23-41-07.bpo-23544.3etemb.rst new file mode 100644 index 00000000000..aa6b504a793 --- /dev/null +++ b/Misc/NEWS.d/next/IDLE/2019-11-14-23-41-07.bpo-23544.3etemb.rst @@ -0,0 +1,2 @@ +The "Stack Viewer" item in the "Debug" menu can no longer be selected when +user code is running.