From fcf1d003bf4f0100c9d0921ff3d70e1127ca1b71 Mon Sep 17 00:00:00 2001
From: Tal Einat
Date: Sat, 6 Jul 2019 15:35:24 +0300
Subject: bpo-26806: add 30 to the recursion limit in IDLE's shell (GH-13944)
This is done to compensate for the extra stack frames added by
IDLE itself, which cause problems when setting the recursion limit
to low values.
This wraps sys.setrecursionlimit() and sys.getrecursionlimit()
as invisibly as possible.
---
Doc/library/idle.rst | 4 +
Lib/idlelib/NEWS.txt | 5 +
Lib/idlelib/help.html | 208 ++++++++-------------
Lib/idlelib/idle_test/test_run.py | 33 ++++
Lib/idlelib/run.py | 62 ++++++
.../IDLE/2019-06-10-22-48-50.bpo-26806.Zltkum.rst | 4 +
6 files changed, 181 insertions(+), 135 deletions(-)
create mode 100644 Misc/NEWS.d/next/IDLE/2019-06-10-22-48-50.bpo-26806.Zltkum.rst
diff --git a/Doc/library/idle.rst b/Doc/library/idle.rst
index fb886a714d..de58f266bf 100644
--- a/Doc/library/idle.rst
+++ b/Doc/library/idle.rst
@@ -713,6 +713,10 @@ or ``print`` or ``write`` to sys.stdout or sys.stderr,
IDLE should be started in a command line window. The secondary subprocess
will then be attached to that window for input and output.
+The IDLE code running in the execution process adds frames to the call stack
+that would not be there otherwise. IDLE wraps ``sys.getrecursionlimit`` and
+``sys.setrecursionlimit`` to reduce the effect of the additional stack frames.
+
If ``sys`` is reset by user code, such as with ``importlib.reload(sys)``,
IDLE's changes are lost and input from the keyboard and output to the screen
will not work correctly.
diff --git a/Lib/idlelib/NEWS.txt b/Lib/idlelib/NEWS.txt
index 689539e73c..5d4a936d63 100644
--- a/Lib/idlelib/NEWS.txt
+++ b/Lib/idlelib/NEWS.txt
@@ -3,6 +3,11 @@ Released on 2019-10-20?
======================================
+bpo-26806: To compensate for stack frames added by IDLE and avoid
+possible problems with low recursion limits, add 30 to limits in the
+user code execution process. Subtract 30 when reporting recursion
+limits to make this addition mostly transparent.
+
bpo-37325: Fix tab focus traversal order for help source and custom
run dialogs.
diff --git a/Lib/idlelib/help.html b/Lib/idlelib/help.html
index 91803fd06c..cee6887df6 100644
--- a/Lib/idlelib/help.html
+++ b/Lib/idlelib/help.html
@@ -14,7 +14,7 @@
-
+
@@ -135,113 +135,75 @@ described below are moved around to conform to Apple guidelines.
File menu (Shell and Editor)
-- New File
-- Create a new file editing window.
-- Open…
-- Open an existing file with an Open dialog.
-- Recent Files
-- Open a list of recent files. Click one to open it.
-- Open Module…
-- Open an existing module (searches sys.path).
+- New File
- Create a new file editing window.
+- Open…
- Open an existing file with an Open dialog.
+- Recent Files
- Open a list of recent files. Click one to open it.
+- Open Module…
- Open an existing module (searches sys.path).
-- Class Browser
-- Show functions, classes, and methods in the current Editor file in a
+
- Class Browser
- Show functions, classes, and methods in the current Editor file in a
tree structure. In the shell, open a module first.
-- Path Browser
-- Show sys.path directories, modules, functions, classes and methods in a
+
- Path Browser
- Show sys.path directories, modules, functions, classes and methods in a
tree structure.
-- Save
-- Save the current window to the associated file, if there is one. Windows
+
- Save
- Save the current window to the associated file, if there is one. Windows
that have been changed since being opened or last saved have a * before
and after the window title. If there is no associated file,
do Save As instead.
-- Save As…
-- Save the current window with a Save As dialog. The file saved becomes the
+
- Save As…
- Save the current window with a Save As dialog. The file saved becomes the
new associated file for the window.
-- Save Copy As…
-- Save the current window to different file without changing the associated
+
- Save Copy As…
- Save the current window to different file without changing the associated
file.
-- Print Window
-- Print the current window to the default printer.
-- Close
-- Close the current window (ask to save if unsaved).
-- Exit
-- Close all windows and quit IDLE (ask to save unsaved windows).
+- Print Window
- Print the current window to the default printer.
+- Close
- Close the current window (ask to save if unsaved).
+- Exit
- Close all windows and quit IDLE (ask to save unsaved windows).
Edit menu (Shell and Editor)
-- Undo
-- Undo the last change to the current window. A maximum of 1000 changes may
+
- Undo
- Undo the last change to the current window. A maximum of 1000 changes may
be undone.
-- Redo
-- Redo the last undone change to the current window.
-- Cut
-- Copy selection into the system-wide clipboard; then delete the selection.
-- Copy
-- Copy selection into the system-wide clipboard.
-- Paste
-- Insert contents of the system-wide clipboard into the current window.
+- Redo
- Redo the last undone change to the current window.
+- Cut
- Copy selection into the system-wide clipboard; then delete the selection.
+- Copy
- Copy selection into the system-wide clipboard.
+- Paste
- Insert contents of the system-wide clipboard into the current window.
The clipboard functions are also available in context menus.
-- Select All
-- Select the entire contents of the current window.
-- Find…
-- Open a search dialog with many options
-- Find Again
-- Repeat the last search, if there is one.
-- Find Selection
-- Search for the currently selected string, if there is one.
-- Find in Files…
-- Open a file search dialog. Put results in a new output window.
-- Replace…
-- Open a search-and-replace dialog.
-- Go to Line
-- Move cursor to the line number requested and make that line visible.
-- Show Completions
-- Open a scrollable list allowing selection of keywords and attributes. See
+
- Select All
- Select the entire contents of the current window.
+- Find…
- Open a search dialog with many options
+- Find Again
- Repeat the last search, if there is one.
+- Find Selection
- Search for the currently selected string, if there is one.
+- Find in Files…
- Open a file search dialog. Put results in a new output window.
+- Replace…
- Open a search-and-replace dialog.
+- Go to Line
- Move cursor to the line number requested and make that line visible.
+- Show Completions
- Open a scrollable list allowing selection of keywords and attributes. See
Completions in the Editing and navigation section below.
-- Expand Word
-- Expand a prefix you have typed to match a full word in the same window;
+
- Expand Word
- Expand a prefix you have typed to match a full word in the same window;
repeat to get a different expansion.
-- Show call tip
-- After an unclosed parenthesis for a function, open a small window with
+
- Show call tip
- After an unclosed parenthesis for a function, open a small window with
function parameter hints. See Calltips in the
Editing and navigation section below.
-- Show surrounding parens
-- Highlight the surrounding parenthesis.
+- Show surrounding parens
- Highlight the surrounding parenthesis.