aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2021-01-28 17:47:41 -0800
committerGitHub <noreply@github.com>2021-01-28 20:47:41 -0500
commit901a9834420e516c07d6cad356d2be481db6d8d1 (patch)
tree418fe88925f207a8a5e06db5b2d5b9303fffaa38
parentbpo-29076: Add fish support to macOS installer (GH-23302) (GH-23938) (diff)
downloadcpython-901a9834420e516c07d6cad356d2be481db6d8d1.tar.gz
cpython-901a9834420e516c07d6cad356d2be481db6d8d1.tar.bz2
cpython-901a9834420e516c07d6cad356d2be481db6d8d1.zip
bpo-23544: Disable IDLE Stack Viewer when running user code (GH-17163) (#24366)
Starting stack viewer when user code is running, including when Debugger is active, hangs or crashes IDLE. Co-authored-by: Zackery Spytz <zspytz@gmail.com> Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu> (cherry picked from commit 23a567c11ca36eedde0e119443c85cc16075deaf)
-rw-r--r--Lib/idlelib/NEWS.txt3
-rw-r--r--Lib/idlelib/codecontext.py2
-rw-r--r--Lib/idlelib/editor.py10
-rw-r--r--Lib/idlelib/idle_test/test_mainmenu.py21
-rwxr-xr-xLib/idlelib/pyshell.py4
-rw-r--r--Misc/NEWS.d/next/IDLE/2019-11-14-23-41-07.bpo-23544.3etemb.rst2
6 files changed, 37 insertions, 5 deletions
diff --git a/Lib/idlelib/NEWS.txt b/Lib/idlelib/NEWS.txt
index 0affc55da8..522ce59f61 100644
--- a/Lib/idlelib/NEWS.txt
+++ b/Lib/idlelib/NEWS.txt
@@ -3,6 +3,9 @@ Released on 2021-02-15?
======================================
+bpo-23544: Disable Debug=>Stack Viewer when user code is running or
+Debugger is active, to prevent hang or crash. Patch by Zackery Spytz.
+
bpo-43008: Make IDLE invoke :func:`sys.excepthook` in normal,
2-process mode.
diff --git a/Lib/idlelib/codecontext.py b/Lib/idlelib/codecontext.py
index eb19773f56..f2f44f5f8d 100644
--- a/Lib/idlelib/codecontext.py
+++ b/Lib/idlelib/codecontext.py
@@ -142,7 +142,7 @@ class CodeContext:
self.text.after_cancel(self.t1)
self._reset()
menu_status = 'Show'
- self.editwin.update_menu_label(menu='options', index='* Code Context',
+ self.editwin.update_menu_label(menu='options', index='*ode*ontext',
label=f'{menu_status} Code Context')
return "break"
diff --git a/Lib/idlelib/editor.py b/Lib/idlelib/editor.py
index 66e9da5a9d..b9cb50264f 100644
--- a/Lib/idlelib/editor.py
+++ b/Lib/idlelib/editor.py
@@ -339,7 +339,7 @@ class EditorWindow:
text.bind("<<toggle-code-context>>",
self.code_context.toggle_code_context_event)
else:
- self.update_menu_state('options', '*Code Context', 'disabled')
+ self.update_menu_state('options', '*ode*ontext', 'disabled')
if self.allow_line_numbers:
self.line_numbers = self.LineNumbers(self)
if idleConf.GetOption('main', 'EditorWindow',
@@ -347,7 +347,7 @@ class EditorWindow:
self.toggle_line_numbers_event()
text.bind("<<toggle-line-numbers>>", self.toggle_line_numbers_event)
else:
- self.update_menu_state('options', '*Line Numbers', 'disabled')
+ self.update_menu_state('options', '*ine*umbers', 'disabled')
def handle_winconfig(self, event=None):
self.set_width()
@@ -450,7 +450,9 @@ class EditorWindow:
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
@@ -1527,7 +1529,7 @@ class EditorWindow:
else:
self.line_numbers.show_sidebar()
menu_label = "Hide"
- self.update_menu_label(menu='options', index='*Line Numbers',
+ self.update_menu_label(menu='options', index='*ine*umbers',
label=f'{menu_label} Line Numbers')
# "line.col" -> line, as an int
diff --git a/Lib/idlelib/idle_test/test_mainmenu.py b/Lib/idlelib/idle_test/test_mainmenu.py
index 7ec0368371..51d2accfe4 100644
--- a/Lib/idlelib/idle_test/test_mainmenu.py
+++ b/Lib/idlelib/idle_test/test_mainmenu.py
@@ -2,6 +2,7 @@
# Reported as 88%; mocking turtledemo absence would have no point.
from idlelib import mainmenu
+import re
import unittest
@@ -16,6 +17,26 @@ class MainMenuTest(unittest.TestCase):
def test_default_keydefs(self):
self.assertGreaterEqual(len(mainmenu.default_keydefs), 50)
+ def test_tcl_indexes(self):
+ # Test tcl patterns used to find menuitem to alter.
+ # On failure, change pattern here and in function(s).
+ # Patterns here have '.*' for re instead of '*' for tcl.
+ for menu, pattern in (
+ ('debug', '.*tack.*iewer'), # PyShell.debug_menu_postcommand
+ ('options', '.*ode.*ontext'), # EW.__init__, CodeContext.toggle...
+ ('options', '.*ine.*umbers'), # EW.__init__, EW.toggle...event.
+ ):
+ with self.subTest(menu=menu, pattern=pattern):
+ for menutup in mainmenu.menudefs:
+ if menutup[0] == menu:
+ break
+ else:
+ self.assertTrue(0, f"{menu} not in menudefs")
+ self.assertTrue(any(re.search(pattern, menuitem[0])
+ for menuitem in menutup[1]
+ if menuitem is not None), # Separator.
+ f"{pattern} not in {menu}")
+
if __name__ == '__main__':
unittest.main(verbosity=2)
diff --git a/Lib/idlelib/pyshell.py b/Lib/idlelib/pyshell.py
index d32106c983..fea3762461 100755
--- a/Lib/idlelib/pyshell.py
+++ b/Lib/idlelib/pyshell.py
@@ -989,6 +989,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', '*tack*iewer', 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 0000000000..eb4a56bf10
--- /dev/null
+++ b/Misc/NEWS.d/next/IDLE/2019-11-14-23-41-07.bpo-23544.3etemb.rst
@@ -0,0 +1,2 @@
+Disable Debug=>Stack Viewer when user code is running or Debugger
+is active, to prevent hang or crash. Patch by Zackery Spytz.