From cba80bff5fc7fc70dec7c717b48280bca6e6eb31 Mon Sep 17 00:00:00 2001 From: Terry Jan Reedy Date: Mon, 5 Nov 2018 23:23:39 -0500 Subject: [PATCH 1/8] bpo-23220: Explain how IDLE's Shell displays output. --- Doc/library/idle.rst | 48 +++++++++++++++---- Lib/idlelib/help.html | 40 ++++++++++++---- .../2018-11-05-23-23-00.bpo-23220.H3SAWE.rst | 1 + 3 files changed, 71 insertions(+), 18 deletions(-) create mode 100644 Misc/NEWS.d/next/IDLE/2018-11-05-23-23-00.bpo-23220.H3SAWE.rst diff --git a/Doc/library/idle.rst b/Doc/library/idle.rst index c5015bf30cfb78f..cca023450bc001d 100644 --- a/Doc/library/idle.rst +++ b/Doc/library/idle.rst @@ -502,6 +502,11 @@ or immediately run an existing file before editing. Python Shell window ^^^^^^^^^^^^^^^^^^^ +With IDLE's Shell, one enters, edits, and recalls complete statements. +Most consoles and terminals only work with a single physical line at a time. +If one pastes more that one statement into Shell, Shell ignores anything +past the first statement. + The editing features described above work when entering code interactively. IDLE's Shell window also responds to the following keys. @@ -520,16 +525,6 @@ IDLE's Shell window also responds to the following keys. * :kbd:`Return` while on any previous command retrieves that command -Shell has a special facility for squeezing output lines down to a -'Squeezed text' label. This is done automatically for output over N lines -(N = 50 by default). N can be changed in the PyShell section of the General -page of the Settings dialog. Output with fewer lines can be squeezed by -right clicking on the output. This can be useful for extra long lines. - -Squeezed output is expanded in place by double-clicking the label. -It can also be sent to the clipboard or a separate view window by -right-clicking the label. - Text colors ^^^^^^^^^^^ @@ -666,6 +661,39 @@ 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. +User output in Shell +^^^^^^^^^^^^^^^^^^^^ + +When a program outputs text, the result is determined by the +corresponding output device. When IDLE executes user code, sys.stdout +and sys.stderr are connected to the display area of IDLE's Shell. Some of +its features are inherited from the underlying tcl/tk Text widget. Others +are programmed additions. + +Text widgets display a subset of Unicode, the Basic Multilingual Plane (BMP). +Which characters get a proper glyph instead of a replacement box depends on +the operating system and installed fonts. Newline characters cause following +text to appear on a new line, but control characters are otherwise ignored. + +Normal and error output are generally kept separate (on separate lines) +from code input and each other, They each get different highlight colors. + +For SyntaxError tracebacks, the normal '^' marking where the error was +detected is replaced by coloring the text with an error highlight. +When code run from a file causes other exceptions, one may right click +on a traceback line to jump to the corresponding line in an IDLE editor. +The file will be opened if necessary. + +Shell has a special facility for squeezing output lines down to a +'Squeezed text' label. This is done automatically for output over N lines +(N = 50 by default). N can be changed in the PyShell section of the General +page of the Settings dialog. Output with fewer lines can be squeezed by +right clicking on the output. This can be useful for extra long lines. + +Squeezed output is expanded in place by double-clicking the label. +It can also be sent to the clipboard or a separate view window by +right-clicking the label. + Developing tkinter applications ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/Lib/idlelib/help.html b/Lib/idlelib/help.html index 1cd9b6913de8b96..1541a91785587ab 100644 --- a/Lib/idlelib/help.html +++ b/Lib/idlelib/help.html @@ -501,6 +501,10 @@

Calltips

Python Shell window

+

With IDLE’s Shell, one enters, edits, and recalls complete statements. +Most consoles and terminals only work with a single physical line at a time. +If one pastes more that one statement into Shell, Shell ignores anything +past the first statement.

The editing features described above work when entering code interactively. IDLE’s Shell window also responds to the following keys.

diff --git a/Misc/NEWS.d/next/IDLE/2018-11-05-23-23-00.bpo-23220.H3SAWE.rst b/Misc/NEWS.d/next/IDLE/2018-11-05-23-23-00.bpo-23220.H3SAWE.rst new file mode 100644 index 000000000000000..77c71268dddd4e8 --- /dev/null +++ b/Misc/NEWS.d/next/IDLE/2018-11-05-23-23-00.bpo-23220.H3SAWE.rst @@ -0,0 +1 @@ +Explain how IDLE's Shell displays output. From c28f609c4efb46fc9204920f9b3f67c7c17a6d35 Mon Sep 17 00:00:00 2001 From: Terry Jan Reedy Date: Mon, 5 Nov 2018 23:43:42 -0500 Subject: [PATCH 2/8] Correct 'ignore' to 'replace'. --- Doc/library/idle.rst | 5 ++++- Lib/idlelib/help.html | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/Doc/library/idle.rst b/Doc/library/idle.rst index cca023450bc001d..509424aaf05ffed 100644 --- a/Doc/library/idle.rst +++ b/Doc/library/idle.rst @@ -673,7 +673,10 @@ are programmed additions. Text widgets display a subset of Unicode, the Basic Multilingual Plane (BMP). Which characters get a proper glyph instead of a replacement box depends on the operating system and installed fonts. Newline characters cause following -text to appear on a new line, but control characters are otherwise ignored. +text to appear on a new line, but other control characters are replaced +with a box. But note that the ``repr`` function, which is used for +interactive echo of expression values, replaces control characters +with escape codes before they are output. Normal and error output are generally kept separate (on separate lines) from code input and each other, They each get different highlight colors. diff --git a/Lib/idlelib/help.html b/Lib/idlelib/help.html index 1541a91785587ab..c188aa1108d51ee 100644 --- a/Lib/idlelib/help.html +++ b/Lib/idlelib/help.html @@ -650,7 +650,10 @@

User output in ShellText widgets display a subset of Unicode, the Basic Multilingual Plane (BMP). Which characters get a proper glyph instead of a replacement box depends on the operating system and installed fonts. Newline characters cause following -text to appear on a new line, but control characters are otherwise ignored.

+text to appear on a new line, but other control characters are replaced +with a box. But note that the repr function, which is used for +interactive echo of expression values, replaces control characters +with escape codes before they are output.

Normal and error output are generally kept separate (on separate lines) from code input and each other, They each get different highlight colors.

For SyntaxError tracebacks, the normal ‘^’ marking where the error was From edebafa424d440c7edb9c035a98229e6494fac9e Mon Sep 17 00:00:00 2001 From: Serhiy Storchaka Date: Tue, 6 Nov 2018 10:32:23 -0500 Subject: [PATCH 3/8] Update Doc/library/idle.rst Co-Authored-By: terryjreedy --- Doc/library/idle.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/library/idle.rst b/Doc/library/idle.rst index 509424aaf05ffed..5f2892dde222588 100644 --- a/Doc/library/idle.rst +++ b/Doc/library/idle.rst @@ -679,7 +679,7 @@ interactive echo of expression values, replaces control characters with escape codes before they are output. Normal and error output are generally kept separate (on separate lines) -from code input and each other, They each get different highlight colors. +from code input and each other. They each get different highlight colors. For SyntaxError tracebacks, the normal '^' marking where the error was detected is replaced by coloring the text with an error highlight. From a3ad4094e16166adb31262d2e9380823c0f2ebcb Mon Sep 17 00:00:00 2001 From: Serhiy Storchaka Date: Tue, 6 Nov 2018 10:32:59 -0500 Subject: [PATCH 4/8] Update Doc/library/idle.rst Co-Authored-By: terryjreedy --- Doc/library/idle.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/library/idle.rst b/Doc/library/idle.rst index 5f2892dde222588..f3bf256d4ad538b 100644 --- a/Doc/library/idle.rst +++ b/Doc/library/idle.rst @@ -665,7 +665,7 @@ User output in Shell ^^^^^^^^^^^^^^^^^^^^ When a program outputs text, the result is determined by the -corresponding output device. When IDLE executes user code, sys.stdout +corresponding output device. When IDLE executes user code, ``sys.stdout`` and sys.stderr are connected to the display area of IDLE's Shell. Some of its features are inherited from the underlying tcl/tk Text widget. Others are programmed additions. From 3de4c7e3c922aed2df30e3e48e4da2ab1aebe687 Mon Sep 17 00:00:00 2001 From: Serhiy Storchaka Date: Tue, 6 Nov 2018 10:33:13 -0500 Subject: [PATCH 5/8] Update Doc/library/idle.rst Co-Authored-By: terryjreedy --- Doc/library/idle.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/library/idle.rst b/Doc/library/idle.rst index f3bf256d4ad538b..9d3418097cb88f0 100644 --- a/Doc/library/idle.rst +++ b/Doc/library/idle.rst @@ -666,7 +666,7 @@ User output in Shell When a program outputs text, the result is determined by the corresponding output device. When IDLE executes user code, ``sys.stdout`` -and sys.stderr are connected to the display area of IDLE's Shell. Some of +and ``sys.stderr`` are connected to the display area of IDLE's Shell. Some of its features are inherited from the underlying tcl/tk Text widget. Others are programmed additions. From bd3923d98d5c2f41df8495c106e2f12e48ae940d Mon Sep 17 00:00:00 2001 From: Serhiy Storchaka Date: Tue, 6 Nov 2018 10:33:29 -0500 Subject: [PATCH 6/8] Update Doc/library/idle.rst Co-Authored-By: terryjreedy --- Doc/library/idle.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/library/idle.rst b/Doc/library/idle.rst index 9d3418097cb88f0..144125237e29ba6 100644 --- a/Doc/library/idle.rst +++ b/Doc/library/idle.rst @@ -667,7 +667,7 @@ User output in Shell When a program outputs text, the result is determined by the corresponding output device. When IDLE executes user code, ``sys.stdout`` and ``sys.stderr`` are connected to the display area of IDLE's Shell. Some of -its features are inherited from the underlying tcl/tk Text widget. Others +its features are inherited from the underlying Tk Text widget. Others are programmed additions. Text widgets display a subset of Unicode, the Basic Multilingual Plane (BMP). From 85139ac1d09f838b6405e20d625fecc46afda5c9 Mon Sep 17 00:00:00 2001 From: Serhiy Storchaka Date: Tue, 6 Nov 2018 10:33:47 -0500 Subject: [PATCH 7/8] Update Doc/library/idle.rst Co-Authored-By: terryjreedy --- Doc/library/idle.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/library/idle.rst b/Doc/library/idle.rst index 144125237e29ba6..bf66feaa4fed30e 100644 --- a/Doc/library/idle.rst +++ b/Doc/library/idle.rst @@ -674,7 +674,7 @@ Text widgets display a subset of Unicode, the Basic Multilingual Plane (BMP). Which characters get a proper glyph instead of a replacement box depends on the operating system and installed fonts. Newline characters cause following text to appear on a new line, but other control characters are replaced -with a box. But note that the ``repr`` function, which is used for +with a box. But note that the ``repr()`` function, which is used for interactive echo of expression values, replaces control characters with escape codes before they are output. From fc6a430eef3121985f6e3ba788a5636c14bfca86 Mon Sep 17 00:00:00 2001 From: Terry Jan Reedy Date: Tue, 6 Nov 2018 11:46:16 -0500 Subject: [PATCH 8/8] Multiline pastes generate SyntaxError --- Doc/library/idle.rst | 19 ++++++++++++------- Lib/idlelib/help.html | 32 ++++++++++++++++++-------------- 2 files changed, 30 insertions(+), 21 deletions(-) diff --git a/Doc/library/idle.rst b/Doc/library/idle.rst index bf66feaa4fed30e..fa58e2d594217d1 100644 --- a/Doc/library/idle.rst +++ b/Doc/library/idle.rst @@ -504,11 +504,14 @@ Python Shell window With IDLE's Shell, one enters, edits, and recalls complete statements. Most consoles and terminals only work with a single physical line at a time. -If one pastes more that one statement into Shell, Shell ignores anything -past the first statement. -The editing features described above work when entering code interactively. -IDLE's Shell window also responds to the following keys. +When one pastes code into Shell, it is not compiled and possibly executed +until one hits :kbd:`Return`. One may edit pasted code first. +If one pastes more that one statement into Shell, the result will be a +:exc:`SyntaxError` when multiple statements are compiled as if they were one. + +The editing features described in previous subsections work when entering +code interactively. IDLE's Shell window also responds to the following keys. * :kbd:`C-c` interrupts executing command @@ -688,10 +691,12 @@ on a traceback line to jump to the corresponding line in an IDLE editor. The file will be opened if necessary. Shell has a special facility for squeezing output lines down to a -'Squeezed text' label. This is done automatically for output over N lines -(N = 50 by default). N can be changed in the PyShell section of the General +'Squeezed text' label. This is done automatically +for output over N lines (N = 50 by default). +N can be changed in the PyShell section of the General page of the Settings dialog. Output with fewer lines can be squeezed by -right clicking on the output. This can be useful for extra long lines. +right clicking on the output. This can be useful lines long enough to slow +down scrolling. Squeezed output is expanded in place by double-clicking the label. It can also be sent to the clipboard or a separate view window by diff --git a/Lib/idlelib/help.html b/Lib/idlelib/help.html index c188aa1108d51ee..83bd4a1b91df9d5 100644 --- a/Lib/idlelib/help.html +++ b/Lib/idlelib/help.html @@ -502,11 +502,13 @@

Calltips

Python Shell window

With IDLE’s Shell, one enters, edits, and recalls complete statements. -Most consoles and terminals only work with a single physical line at a time. -If one pastes more that one statement into Shell, Shell ignores anything -past the first statement.

-

The editing features described above work when entering code interactively. -IDLE’s Shell window also responds to the following keys.

+Most consoles and terminals only work with a single physical line at a time.

+

When one pastes code into Shell, it is not compiled and possibly executed +until one hits Return. One may edit pasted code first. +If one pastes more that one statement into Shell, the result will be a +SyntaxError when multiple statements are compiled as if they were one.

+

The editing features described in previous subsections work when entering +code interactively. IDLE’s Shell window also responds to the following keys.

  • C-c interrupts executing command

  • @@ -643,29 +645,31 @@

    Running user code

    User output in Shell

    When a program outputs text, the result is determined by the -corresponding output device. When IDLE executes user code, sys.stdout -and sys.stderr are connected to the display area of IDLE’s Shell. Some of -its features are inherited from the underlying tcl/tk Text widget. Others +corresponding output device. When IDLE executes user code, sys.stdout +and sys.stderr are connected to the display area of IDLE’s Shell. Some of +its features are inherited from the underlying Tk Text widget. Others are programmed additions.

    Text widgets display a subset of Unicode, the Basic Multilingual Plane (BMP). Which characters get a proper glyph instead of a replacement box depends on the operating system and installed fonts. Newline characters cause following text to appear on a new line, but other control characters are replaced -with a box. But note that the repr function, which is used for +with a box. But note that the repr() function, which is used for interactive echo of expression values, replaces control characters with escape codes before they are output.

    Normal and error output are generally kept separate (on separate lines) -from code input and each other, They each get different highlight colors.

    +from code input and each other. They each get different highlight colors.

    For SyntaxError tracebacks, the normal ‘^’ marking where the error was detected is replaced by coloring the text with an error highlight. When code run from a file causes other exceptions, one may right click on a traceback line to jump to the corresponding line in an IDLE editor. The file will be opened if necessary.

    Shell has a special facility for squeezing output lines down to a -‘Squeezed text’ label. This is done automatically for output over N lines -(N = 50 by default). N can be changed in the PyShell section of the General +‘Squeezed text’ label. This is done automatically +for output over N lines (N = 50 by default). +N can be changed in the PyShell section of the General page of the Settings dialog. Output with fewer lines can be squeezed by -right clicking on the output. This can be useful for extra long lines.

    +right clicking on the output. This can be useful lines long enough to slow +down scrolling.

    Squeezed output is expanded in place by double-clicking the label. It can also be sent to the clipboard or a separate view window by right-clicking the label.

    @@ -878,7 +882,7 @@

    Navigation



    - Last updated on Nov 05, 2018. + Last updated on Nov 06, 2018. Found a bug?