This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: macOS IDLE with Tk 8.6.10 in 3.9.1rc1 universal2 installer fails smoke test
Type: Stage: resolved
Components: IDLE, macOS, Tkinter Versions: Python 3.10, Python 3.9, Python 3.8
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: terry.reedy Nosy List: miss-islington, ned.deily, ronaldoussoren, serhiy.storchaka, terry.reedy, wordtech
Priority: critical Keywords: patch

Created on 2020-11-30 03:17 by ned.deily, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 23570 merged terry.reedy, 2020-11-30 16:44
PR 23571 merged miss-islington, 2020-11-30 17:09
PR 23572 merged miss-islington, 2020-11-30 17:10
PR 23577 merged terry.reedy, 2020-12-01 00:52
PR 23669 merged miss-islington, 2020-12-07 03:22
PR 23670 merged miss-islington, 2020-12-07 03:23
Messages (13)
msg382110 - (view) Author: Ned Deily (ned.deily) * (Python committer) Date: 2020-11-30 03:17
An IDLE installation manual smoke test gives odd behavior when run on macOS using the Tcl/Tk 8.6.10 introduced with the new macOS universal2 installer variant as of 3.9.1rc1.  The test behaves as expected (without the duplicate and spurious error messages) when run using the traditional macOS 10.9 installer variant that includes Tcl/Tk 8.6.8 built on macOS 10.9.

The test consists of: 
- launch the new IDLE by double-clicking on its icon in the applicable /Applications/Python 3.x folder
- press cmd-N to open a new edit window
- enter a three-line snippet with a syntax error, something like:
  x = 1
  y = $2
- press cmd-S to save the file entering any valid file name
- press F5 to run the snippet
- observe the popup "Invalid syntax" error window
- click OK to dismiss and observe previous "Invalid syntax" window replaced by an identical error window [ERROR]
- click OK to dismiss
- remove the syntax error and press cmd-S to resave
- press F5 to run again
- observe the output of the print function in the IDLE shell window
- observe popup error window over IDLE shell window with "The Python Shell window is already executing a command: please wait until it is finished." [ERROR]
- click OK to dismiss and observe previous "already executing" window replaced by an identical error window [ERROR]
- click OK to dismiss
- press cmd-Q to quit IDLE

As we are planning to introduce the universal2 installer variant on 3.8.x and 3.10 to natively support Apple Silicon Macs and macOS 11 Big Sur, a quick resolution of this issue is important. While automated tests in the test suite show no new failures, it would be good to manually exercise IDLE in the new installer configuration to look for other unusual behaviors.
msg382165 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2020-11-30 17:09
New changeset e41bfd15dd148627b4f39c2a5837bddd8894d345 by Terry Jan Reedy in branch 'master':
bpo-42508: Remove bogus idlelib.pyshell.ModifiedInterpreter attribute (GH-23570)
msg382166 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2020-11-30 17:22
This issue exposed and is affected by an existing system and version independent bug.  With that fixed as in PR 23570, running a file with "print('output')" with the new 3.9.1rc1 universal binary results in the following.

========= RESTART: /Users/.../ =========
<'... finished.' dialog box>
<click OK and box reappears>
<click again and>
========== RESTART: Shell =====================

The normal output is

========= RESTART: /Users/.../ =========

I am investigating how 'RESTART' is being printed after 'output', even though the restart function is called before the compiled tem1 is sent to be executed.
msg382167 - (view) Author: miss-islington (miss-islington) Date: 2020-11-30 17:30
New changeset f4389bfbb5b9f67db1505dd0003987896eae560b by Miss Islington (bot) in branch '3.8':
bpo-42508: Remove bogus idlelib.pyshell.ModifiedInterpreter attribute (GH-23570)
msg382201 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2020-11-30 22:30
After hours of failure to understand crazy 'impossible' behavior, I went back to 'timing issue' and this code.

    def run_module_event(self, event):
        if macosx.isCocoaTk():
            # Tk-Cocoa in MacOSX is broken until at least
            # Tk 8.5.9, and without this rather
            # crude workaround IDLE would hang when a user
            # tries to run a module using the keyboard shortcut
            # (the menu item works fine).
                lambda: self.editwin.text_frame.event_generate(
            return 'break'
            return self._run_module_event(event)

When I used the Run menu instead of F5, the problem went away.  The problem also went away when I added 'and 0' to the condition above to disable the workaround.  3.8 also works fine with the workaround disabled.  Ned, if you verify enough to agree, I will get rid of the wrapper and remove the leading '_' from the real handler.
msg382203 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2020-11-30 22:36
New changeset ff51e5ec26168574761e128cc607b879d4d5aa50 by Miss Islington (bot) in branch '3.9':
bpo-42508: Remove bogus idlelib.pyshell.ModifiedInterpreter attribute (GH-23570) (GH-23571)
msg382210 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2020-12-01 00:53
PR 23577 makes fix suggested above for easier review.
msg382327 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2020-12-02 17:13
The new tk/tkinter bug in the macOS11 U2 build, other than those reported in #42507 and #42541, is that pressing F5 causes the corresponding pseudoevent handler, run_module_event, to be called twice.  (Its code is above.)  The interval between calls is about 1 millesecond -- .7 to 1.1 in 5 tries.  See this by adding the following at the top of the function's and subtracting after running code with or without syntax  error.
  print('run', time.perf_counter())

Adding multiple prints in _run_module_event shows the following for code that compiles.  With the 200 millesecond cocoa delay, the two calls run interleaved closely interleaved.  I don't understand the details, but the result is the scrambled and incorrect output given above.  With no delay as with PR 23577, the first call calls restart_subprocess in _run_module_event.  Then call 2 gets to the top of this function, then call 1 appears to finish, and call 2 is somehow aborted.

With a syntax error, the 2nd call, redisplaying the error, is not aborted.

F5 resulting in two calls is not unique, even though I have not yet seen overt double call effects.  In Shell, Control-F6 restarts.  A print in its event handler shows that it is called twice even though there is only 1 restart.

A possible kludge workaround would be to call perf_counter when the class is created and for Cocoa, each run_module call.  Return when new-old < 2milliseconds.  But the double call should be fixed as it could show up elsewhere.
msg382435 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2020-12-03 18:16
The new commit to PR 23577 works around the double run_module_event call.  Removing the delay changed timings, so I instead measured the time between closing the errorbox and the 2nd call.  The allowed difference had to be increased to .015, so I selected .05 to be safer.
msg382619 - (view) Author: Ned Deily (ned.deily) * (Python committer) Date: 2020-12-07 03:22
New changeset 57e511361047895231f5ee7abfdfbbc60e11d2db by Terry Jan Reedy in branch 'master':
bpo-42508: Keep IDLE running on macOS (GH-23577)
msg382620 - (view) Author: Ned Deily (ned.deily) * (Python committer) Date: 2020-12-07 03:49
New changeset 2a9a883d361d37b40fb0b0011dd300bb83ceb73c by Miss Islington (bot) in branch '3.9':
bpo-42508: Keep IDLE running on macOS (GH-23577) (GH-23669)
msg384374 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2021-01-05 08:09
New changeset d05b470d6ad6dfe0d4933ffc3c5c1e2c03b390bd by Miss Islington (bot) in branch '3.8':
bpo-42508: Keep IDLE running on macOS (GH-23577) (#23670)
msg384375 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2021-01-05 08:10
I believe that this issue is done.  Please open a new one if more is needed.
Date User Action Args
2022-04-11 14:59:38adminsetgithub: 86674
2021-01-05 08:10:47terry.reedysetstatus: open -> closed
resolution: fixed
messages: + msg384375

stage: patch review -> resolved
2021-01-05 08:09:38terry.reedysetmessages: + msg384374
2020-12-07 03:49:05ned.deilysetmessages: + msg382620
2020-12-07 03:23:02miss-islingtonsetpull_requests: + pull_request22537
2020-12-07 03:22:50miss-islingtonsetpull_requests: + pull_request22536
2020-12-07 03:22:45ned.deilysetmessages: + msg382619
2020-12-03 18:16:18terry.reedysetmessages: + msg382435
2020-12-02 17:13:17terry.reedysetnosy: + wordtech, serhiy.storchaka
messages: + msg382327
2020-12-01 10:02:39terry.reedysetstage: patch review
2020-12-01 00:53:47terry.reedysetmessages: + msg382210
stage: patch review -> (no value)
2020-12-01 00:52:38terry.reedysetstage: patch review
pull_requests: + pull_request22456
2020-11-30 22:36:15terry.reedysetmessages: + msg382203
2020-11-30 22:30:26terry.reedysetmessages: + msg382201
2020-11-30 17:30:55miss-islingtonsetmessages: + msg382167
2020-11-30 17:22:58terry.reedysetmessages: + msg382166
stage: patch review -> (no value)
2020-11-30 17:10:06miss-islingtonsetpull_requests: + pull_request22453
2020-11-30 17:09:57miss-islingtonsetnosy: + miss-islington
pull_requests: + pull_request22452
2020-11-30 17:09:52terry.reedysetmessages: + msg382165
2020-11-30 16:44:03terry.reedysetkeywords: + patch
stage: patch review
pull_requests: + pull_request22451
2020-11-30 03:17:54ned.deilycreate