classification
Title: IDLE regression: toggle tabs and change indent width functions
Type: behavior Stage: patch review
Components: IDLE Versions: Python 3.9, Python 3.8, Python 3.7
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: terry.reedy Nosy List: Zero, miss-islington, terry.reedy
Priority: normal Keywords: patch

Created on 2019-10-29 21:14 by Zero, last changed 2019-11-20 06:37 by miss-islington.

Pull Requests
URL Status Linked Edit
PR 17008 merged terry.reedy, 2019-10-31 02:13
PR 17274 merged miss-islington, 2019-11-20 06:19
PR 17275 merged miss-islington, 2019-11-20 06:19
Messages (8)
msg355678 - (view) Author: Stephen Paul Chappell (Zero) Date: 2019-10-29 21:14
In the latest Python 3.8.0 installation when running IDLE on Windows, pressing "Alt + T" generates the following error:

    Exception in Tkinter callback
    Traceback (most recent call last):
      File "C:\Program Files\Python38\Lib\tkinter\__init__.py", line 1883, in __call__
        return self.func(*args)
      File "C:\Program Files\Python38\Lib\idlelib\multicall.py", line 176, in handler
        r = l[i](event)
    TypeError: toggle_tabs_event() missing 1 required positional argument: 'event'

Similarly, pressing "Alt + U" will generate a very similar error:

    Exception in Tkinter callback
    Traceback (most recent call last):
      File "C:\Program Files\Python38\Lib\tkinter\__init__.py", line 1883, in __call__
        return self.func(*args)
      File "C:\Program Files\Python38\Lib\idlelib\multicall.py", line 176, in handler
        r = l[i](event)
    TypeError: change_indentwidth_event() missing 1 required positional argument: 'event'
msg355701 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2019-10-30 09:52
Both the menu items and the short cuts for these two functions on the Format menu give these call errors.  They are only visible if IDLE is started from a console.

They work in 3.6; the regression is due to #36390.  These 2 functions were moved separately from the others in the 3rd PR, PR 14827, changeset 1b3892243433da7eae7f5f3a4f98f13d309c8926.  I found the mistake and believe I have one possible version of a working fix on a new branch.

The diff contains this comment:
  # With mixed indents not allowed, these are semi-useless and not unittested.
I was thinking that they should be removed, but regardless, they should have been manually tested.  However, in one test with 3.6, a mixed indent -- tab + 4 spaces following a 4 space tab -- did work, so I am not sure of the rule.  I will try to add a unittest along with the fix.
msg355712 - (view) Author: Stephen Paul Chappell (Zero) Date: 2019-10-30 12:18
When I start IDLE and the shell window appears, my first task is to press "Alt + T" to change from using tabs to spaces and then "Alt + U" to change from using 8 spaces to 4. This allows code pasted from the shell into an editor window or other IDE to not require reformatting since those settings seem to be common for Python code. If the defaults for these settings were to be exposed in IDLE's settings under the General tab (maybe near the new "Show line numbers in new windows" checkbox), would it be best to make that request here or to open a new bug with an enhancement suggestion?
msg355737 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2019-10-31 01:58
Interesting.  The result of making these changes is legal code looking like
>>> if a:
    if b:
        c = 3
This has been proposed as the way Shell should work, but rejected as likely too confusing to beginners as the indented code does not look indented compared to the line above.  The use of tabs for indents in Shell has long been considered a wart that is a 'least bad solution'.

Please hold your proposals.  I intend to solve the issue by moving the prompt to a shell sidebar and use the same indent in shell as in editors.  #37903 has a PR under review.
msg355738 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2019-10-31 02:20
The old, long discussion of Shell indents is #7676 and a preceding issue reference therein.  My replacement is #37892.

The PR patch is simple enough to apply by to existing 3.7.5 and 3.8.0 installs.
msg357033 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2019-11-20 06:18
New changeset b8462477bfd01ff21461065d5063e6b0238ca809 by Terry Jan Reedy in branch 'master':
bpo-38636: Fix IDLE tab toggle and file indent width (GH-17008)
https://github.com/python/cpython/commit/b8462477bfd01ff21461065d5063e6b0238ca809
msg357034 - (view) Author: miss-islington (miss-islington) Date: 2019-11-20 06:37
New changeset 755caaa753577b907bb7e94560f8adf5eb694d6b by Miss Islington (bot) in branch '3.7':
bpo-38636: Fix IDLE tab toggle and file indent width (GH-17008)
https://github.com/python/cpython/commit/755caaa753577b907bb7e94560f8adf5eb694d6b
msg357035 - (view) Author: miss-islington (miss-islington) Date: 2019-11-20 06:37
New changeset 132243957ce834cf5ffced4bf8e39d00f6e34e5f by Miss Islington (bot) in branch '3.8':
bpo-38636: Fix IDLE tab toggle and file indent width (GH-17008)
https://github.com/python/cpython/commit/132243957ce834cf5ffced4bf8e39d00f6e34e5f
History
Date User Action Args
2019-11-20 06:37:50miss-islingtonsetmessages: + msg357035
2019-11-20 06:37:13miss-islingtonsetnosy: + miss-islington
messages: + msg357034
2019-11-20 06:19:08miss-islingtonsetpull_requests: + pull_request16768
2019-11-20 06:19:01miss-islingtonsetstage: test needed -> patch review
pull_requests: + pull_request16767
2019-11-20 06:18:54terry.reedysetmessages: + msg357033
2019-10-31 02:20:17terry.reedysetmessages: + msg355738
stage: patch review -> test needed
2019-10-31 02:13:22terry.reedysetkeywords: + patch
stage: test needed -> patch review
pull_requests: + pull_request16533
2019-10-31 01:58:11terry.reedysetmessages: + msg355737
2019-10-30 12:18:45Zerosetmessages: + msg355712
2019-10-30 09:52:41terry.reedysettitle: "Alt + T" and "Alt + U" Broken in IDLE on Windows -> IDLE regression: toggle tabs and change indent width functions
components: - Windows

nosy: - paul.moore, tim.golden, zach.ware, steve.dower
versions: + Python 3.7, Python 3.9
messages: + msg355701
stage: test needed
2019-10-29 21:14:08Zerocreate