classification
Title: IDLE on macOS 10.15 Catalina does not open double-clicked files if app already launched
Type: Stage:
Components: IDLE, macOS Versions: Python 3.8
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: ned.deily Nosy List: AndrewGYork, IrvKalb, RM, ned.deily, ronaldoussoren, terry.reedy
Priority: critical Keywords:

Created on 2019-11-30 19:10 by RM, last changed 2020-07-27 17:38 by IrvKalb.

Messages (17)
msg357661 - (view) Author: Ramon (RM) Date: 2019-11-30 19:10
I'm running Python 3.8 and Mac Os Catalina 10.15.1 When I click a .py file, it will open the shell + editor, However if I try to open a new .py file from my finder window it won't open. The only way I can open another file is through the shell by clicking file - open. I downloaded a folder with containing .py files from the web and I have no issue opening those files from my finder window. It appear to be only files created in my computer.
msg357667 - (view) Author: Ned Deily (ned.deily) * (Python committer) Date: 2019-11-30 22:23
Thanks for the report.  If I understand correctly, the issue you are seeing is that, when IDLE is already launched and you double-click on a .py file in the Finder, that .py file does not open in IDLE, even though it will open in IDLE if IDLE is not already launched.  This does seem to be a change in behavior between macOS 10.14 Mojave and 10.15 Catalina. Further investigation is needed.

Of course, launching files in the right application is always somewhat dicey in macOS when there is more than one application claiming an association with a particular file type, like for .py files, so it is always safest to open files from with the app itself, for example, with IDLE's File -> Open menu option.
msg357668 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2019-11-30 23:52
With Mohave, double click on a file name in Finder Documents opens the file in an editor and then opens the shell.  Double click on another file opens the file in another editor (but not a duplicate shell).  These are .py files I saved from IDLE.

Ramon originally posted this on Stackoverflow, where it is slightly off topic.  I suggested posting it here to at least have it documented and see what Ned says and for the off chance that there is something we can do.

I wonder how a downloaded file could be different from a saved file.  Are file permissions as revealed by 'ls -l' in the directory in Terminal the same?
msg366978 - (view) Author: AndrewGYork (AndrewGYork) * Date: 2020-04-22 06:30
We have a 10.15.3 Mac with python 3.8.2, IDLE version 3.8.2, and we see similar behavior.

Summary:
The *second* 'bad' .py file you double-click won't open in IDLE. This seems unrelated to permissions, but a 'bad' file (saved by IDLE) can be converted to a 'good' file by emailing the file to myself.

Details:
Open IDLE, save a 5-byte file 'fails.py' (contents: pass) to an empty folder. Permissions are rw-r--r--.

Close IDLE. Double-click 'fails.py', which opens in the IDLE editor; a shell also opens. Double-click 'fails.py' again, or drag it onto the IDLE icon in the Dock, and it does not open in a second instance of the IDLE editor. Typing `idle3 fails.py` in the terminal does open in a second instance of the IDLE editor (same version as first instance).

Email 'fails.py' to myself, via Gmail. Download 'fails.py' from Gmail, and rename it to 'works.py'. Permissions are still rw-r--r--.

Close IDLE. Double-click 'works.py', which opens in the IDLE editor; a shell also opens. Double-click 'works.py' again, or drag it onto the IDLE icon in the Dock, and it *does* open in a second instance of the IDLE editor. Any number of instances can be simultaneously opened this way.

Close IDLE. Double-click 'works.py' several times to open it in several different instances of the IDLE editor. Double-click 'fails.py' once, which successfully opens in one more instance of the IDLE editor. Finally, double-click 'fails.py' a second time; it does *not* open a second instance of 'fails.py' in the IDLE editor.

IDLE's File->Open menu option does not open two instances of `fails.py` OR `works.py`; attempts to open the second instance simply raise focus of the first instance. However, if you open 'fails.py' via the menu, you can then open a second instance of 'fails.py' via double-clicking, but not a third.
msg366983 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2020-04-22 07:13
By design, IDLE should only allow one editor instance per file for a given python-IDLE process.  "$ python3 fails.py" opens a new python-IDLE process, independent of existing processes. It is possible that double-clicking good.py multiple times opens a new IDLE process each time, without a new Shell.  You could check the process list in Terminal. (I have forgotten the unix command and barely know bash.)
msg369412 - (view) Author: Irv Kalb (IrvKalb) Date: 2020-05-20 01:06
If possible, I would like to raise the priority of this issue.  I teach Python and I use IDLE every day.  This bug makes using IDLE for teaching extremely difficult.

Hopefully new information:

I have just bought a new Mac, which is running Catalina (MacOS 10.15).  I am using Python/IDLE 3.7.3, and I am seeing the same issue.  And it does seem to behave differently depending on if I created the file(s) on my computer (fails) vs downloading files from the internet (opens just fine). 

(For background info, I have used IDLE for years on my older Mac with MacOS 10.12 without seeing this problem.)

I have my Mac Finder set to open all ".py" files using IDLE.app in the Python 3.7 folder.

In the Finder, if I select one or more files and double click, each file opens in an editor window in IDLE.  But after that, with IDLE still open, double clicking on any other .py file is ignored.  I can edit and save any open file, but I can no longer open additional files by double clicking in the Finder, or by dragging a file to the IDLE icon in my Dock.

Further info:  If I am in IDLE and have an editing window open, then I choose to open a different file using File -> Open File, and navigate to another Python file, then the open file closes, and the new file opens - even if I have not saved any changed in the first file.

I never use the command line.  I just double click on Python files, and want to see them open in IDLE.  That's how I teach my students, and I typically have multiple small sample files open at the same time.  This bug makes it impossible to teach and work this way.

If it would help, I would be happy to create a small movie demonstrating this problem.
msg369420 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2020-05-20 06:46
This is not really an IDLE issue; I only tagged it as such to make it easy for IDLE users to find.  It might or not be a python-install Catalina-upgrade issue.  It definitely is an Apple issue in that they care little for Python, nothing for tcl/tk, and released something that broke even 64-bit apps.

On my copy of Mohave, if x.py is open in IDLE, double clicking x.py in Finder does not open x.py in a new window.  Rather, it raises the existing x.py window to the top and makes it the active window.  This is what it should do.

IDLE File=>Open has a shortcut -- Command-O.  Either opens a  IDLE-specific Finder-like window.  The main difference from the Finder-app window is that selections are guaranteed to open in IDLE regardless of Finder/system settings. And once you have a file open, File-open/Command-C opens the IDLE-Finder dialog in the directory containing that file, with that file highlighted and others listed. So I consider this superior to the OS File Manager.  I also make great use of File=>Recent Files to open files.

Irv, file closing when you open another is a different issue from files not opening (but I don't know that a separate tracker issue would be useful).  It seems crazy, and was not reported by anyone else yet, but I will believe it without a movie.  Does this happen with IDLE's open dialog, or only with Finder itself?  If the latter, use the former.
msg369431 - (view) Author: Ned Deily (ned.deily) * (Python committer) Date: 2020-05-20 08:42
Irv, I'm sorry you are having problems and I think it is very reasonable to bump the priority of the issue as you are not alone, even though, as Terry notes, a complete resolution may require changes elsewhere. I am looking more into this now. macOS 10.15 Catalina has introduced a number of changes in the interest of improving your security and some of these have had an impact on both Python and on Tcl/Tk which IDLE uses to power its GUI. While most of the 10.15-specific issues are addressed in the latest release of Python (3.8.3), the issue of double-clicking a file while IDLE is already open is not yet. However, I notice you mention that you are using IDLE from Python 3.7.3. If so, be aware that that is not the latest release of either Python 3 or Python 3.7 (3.7.3 predates Catalina.) 3.7.7 is the most recent for 3.7 but Python 3.8 is now current and its most recent release, 3.8.3, has the most up-to-date support for 10.15. If possible, you should update to 3.8.3 or at least to 3.7.7, which has some. That won't fix everyting but it may make some issues go away.

You also mention the apparent closing of an IDLE edit window when you open another edit window. I have not seen nor am aware of reports of behavior exactly like that; however, I think you might be running into a similar situation to what Andrew reports in an earlier comment (msg366978) in this issue. What you may be going on is a case where trying to open another file to edit in IDLE unexpectedly causes a second instance of IDLE to open, with the original file still open in the original instance (but perhaps with its windows now obscured by other windows) and with the second file open in an edit window in the additional IDLE instance.  That can be very confusing as having more than one instance of the same app running is normally not supposed to happen. One way to tell that this is happening is to check the macOS Dock and see if there is more than one IDLE icon present with the active indicator. If you switch to the other IDLE instance, your original edit window should still be present. (You could also use Mission Control features to see all open windows.)  Let us know if you can determine that the closing window is the second IDLE case with 3.7.3; this problem may not occur with IDLE from 3.8.3 but let us know.

By the way, I am assuming here that you are using Python 3.7.3 downloaded from the python.org website. Let us know if that is not the case.
msg369432 - (view) Author: AndrewGYork (AndrewGYork) * Date: 2020-05-20 09:25
If it's helpful, I'd be happy to do a screenshare session (Google Meet, Zoom, etc), to demonstrate and explore the behavior.

We have a 10.15.4 Mac with python 3.8.3 freshly installed from python.org, Tk version 8.6.8, IDLE version 3.8.3. IDLE file opening functions very differently on this machine then on any Linux or Windows machine I've used in the past decade.
msg369433 - (view) Author: Ned Deily (ned.deily) * (Python committer) Date: 2020-05-20 09:40
Thanks, Andrew, for the offer. I think we have enough to go on right now but we may want to touch base a bit later.

From your comment about how IDLE on macOS is different than it is on Windows or Linux, I assume that means you may be new to IDLE on macOS. Yes, there are a number of sometimes subtle differences. Most of these are differences in how Tk behaves (rather than IDLE itself) and usually with a very good reason: Tk tries very hard to be a "good" citizen in each of the three major windowing environments it is supported: Windows-native, macOS-native, and X11 (Linux and others). As such, Tk tries to look and behave as native applications in each are expected to behave, which leads to subtle but important programming issues, like the fact that macOS applications are expected to have one menu bar that appears at the top of the active display whereas on other platforms, each window may have its own menu bar.  Or Tk uses the macOS-supplied file opening and closing sheets which differ from other platforms, etc etc. That can make using Tk-based apps, like IDLE, more familiar-looking to and easier to learn for macOS users but it can be disconcerting if you are using such an app on multiple platforms. Or perhaps you meant something else.
msg369468 - (view) Author: Irv Kalb (IrvKalb) Date: 2020-05-20 19:14
Thanks for all the message about this issue.

I have made a three-minute video that demonstrates what I am seeing.  Here is a link (the video is marked as "unlisted" so only people with this link can see it):

https://youtu.be/OIu-HCVVDn8

To answer your questions:

- Using 3.7 because I'm a heavy user of Pygame, and my understanding is that 3.8 is not compatible with Pygame now
- Yes, this is an absolutely standard installation from Python.org
- In all my testing, I have never seen multiple instances of IDLE.  There is only one.

I understand from the comments that this may not fully be an IDLE issue, and may require changes from Apple.  

I appreciate anything you can do to help resolve this issue. I am willing to supply any more information and/or do any testing to help.
msg369500 - (view) Author: Ned Deily (ned.deily) * (Python committer) Date: 2020-05-21 06:23
Thank you for going to the trouble to produce the movie, Irv! It was very helpful. It turns out the disappearing window issue is because you are using the macOS 10.6+ Python 3.7.3 installer variant rather than the macOS 10.9+ installer variant. For some reason, the Tk built for 10.6 has this problem but when built for 10.9 it does not. So this problem is, indeed, not the two instances of IDLE behavior I speculated. The fix is simple: don't use the 10.6 variant. In fact, as of the beginning of 2020, we no longer provide the 10.6 variant for any version. I don't have experience with pygame but I did a quick test on 10.15 following the directions on the Pygame Getting Started page and verified that the aliens example worked with the latest 3.7.7 10.9 installer. I also tried with 3.8.3 and saw that the problem there is that the project has not provided a pre-built wheel for Pygame 1.9.6 so the installation fails while trying to build everything from source. I did try their suggestion further down the page to use a pre-release of pygame 2.  The latest prelease, 2.0.0.dev8, does have a prebuilt wheel for 3.8.x on macOS; it installed without issue and the aliens still worked. (Now back to the original issue!)
msg369562 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2020-05-22 07:58
When I say that I am 99% sure that this is not an IDLE issue at all, I mean that I am 99% sure that a non-IDLE tkinter program registered as a working double-click handler in Mohave will not be properly invoked in Catalina.  A counter-example might suggest a possible fix for IDLE.

Likewise, doubt that this is a tkinter issue means that I suspect that a working .tcl Mohave double click handler would fail in Catalina.  A counterexample would suggest looking at tkinter/__init__.py and  _tkiter.py.  For example, #40452 was opened as a Windows-specific IDLE failure, with a PR.  However, Tal Einat discovered that a) the same problem existed on macOS, b) a 4-line tkinter program also failed, c) a 4-line .tcl program worked, and d) on exit, tcl calls code that is no longer called in _tkinter, during python exit (after python was partly torn down).  We expect to fix the issue by calling a narrower acting tcl function before python exit.

IDLE opens existing files with idlelib.filelist.FileList.open.  It gets filenames from the os command line, the tk open file dialog, IDLE's Open Module dialog and Path Browser, and its Recent Files list.  I don't know how an OS file manager passes a filename to this function in a particular process, but I imaging that the GUI framework, the IDLE icon, and the double-click registration information may all be involved.  (On both Windows and macOS, double clicks to not open the file in an existing IDLE opened from a command line.) Anyway, here is an easy experiment with IDLE itself that someone should do on Catalina.

Open x.y Shell an IDLE icon (not the command line).
File => OpenModule idlelib.filelist
At the top of the open() body, after 'def open(self, filename,...)' add
        tkMessageBox.showerror('', filename, master=self.root)
Save and close the editor and shell (*required*).
Open x.y Shell from the same IDLE icon.  It will import the revised filelist module.
Open a file from within IDLE.  A message box appears with the full path and an [OK] button.  Click the button and the new editor window appears.
Double-click a file in Finder.  For me, on Mohave, the same thing happens as above.  I expect that on Catalina, there is no message box, indicating that IDLE's file open function is not called.  If I am wrong, check the displayed path and move the debug line down to find where execution stops.
msg369671 - (view) Author: Irv Kalb (IrvKalb) Date: 2020-05-23 00:13
Thanks Ned and Terry for your responses.

Ned: I am currently teaching a course where my students and I are all using Python 3.7 and the current Pygame 1.9.6, so unfortunately, I cannot update to the newer development release of 2.0.  I am also writing a book on OOP using Pygame, and that is currently dependent on the same Pygame release.

Terry:  I tried following your steps.  I opened the appropriate file (idlelib.filelist), and added the line at the appropriate place.  But when I go to save, I get a message:

[Errno 13] Permission denied: 'Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/idlelib/filelist.py'

So I cannot save the file.

I tried opening the same file a simple text editor, BBEdit, and made the same change.  When I went to save I got a message:

Are you sure you want to unlock filelist.py?  You aren't a member of the group 'wheel'.
      Cancel   Unlock

I chose Unlock, saved and quit.  The Finder shows a new date for the file.  But when I double clicked on my Python 3.7 icon, or if I double click on any Python file, IDLE no longer opens.  

I went back into BBEdit, removed the new line, saved again.  Now I can open IDLE as before.  

I don't have a good feel for what files I am supposed to be "allowed" to edit, so I don't know what to try next.  If you have any suggestions about how I can add your debugging line successfully, I'm happy to help.
msg369678 - (view) Author: Ned Deily (ned.deily) * (Python committer) Date: 2020-05-23 00:43
Irv, thanks for the feedback and the attempt. I think we had a little bit of a misunderstanding on our end so I don't think we need you to try anything more for this problem.

Terry, I apologize if I left the impression that there was some doubt about whether the double-clicking failure was due to a problem in IDLE. This is almost certainly a Tk issue but ultimately we need to be able to address the problem for python.org macOS installers. That's what I am working on right at the moment. I should have something for you and Tal to look at soon and we can proceed from there. Thanks!
msg374143 - (view) Author: Ned Deily (ned.deily) * (Python committer) Date: 2020-07-23 16:09
Ramon, I am not sure why you closed this issue. Perhaps it may no longer be a problem for you, but it has not yet been resolved for users of the python.org macOS installers.
msg374405 - (view) Author: Irv Kalb (IrvKalb) Date: 2020-07-27 17:38
Right.  I'm struggling with this bug every day.

Irv

> On Jul 23, 2020, at 9:09 AM, Ned Deily <report@bugs.python.org> wrote:
> 
> 
> Ned Deily <nad@python.org> added the comment:
> 
> Ramon, I am not sure why you closed this issue. Perhaps it may no longer be a problem for you, but it has not yet been resolved for users of the python.org macOS installers.
> 
> ----------
> stage: resolved -> 
> status: closed -> open
> 
> _______________________________________
> Python tracker <report@bugs.python.org>
> <https://bugs.python.org/issue38946>
> _______________________________________
>
History
Date User Action Args
2020-07-27 17:38:34IrvKalbsetmessages: + msg374405
2020-07-23 16:09:34ned.deilysetstatus: closed -> open

messages: + msg374143
stage: resolved ->
2020-07-23 15:46:36RMsetstatus: open -> closed
stage: resolved
2020-06-16 15:21:23terry.reedylinkissue40991 superseder
2020-05-23 00:43:35ned.deilysetpriority: normal -> critical

messages: + msg369678
2020-05-23 00:13:06IrvKalbsetmessages: + msg369671
2020-05-22 07:58:14terry.reedysetpriority: critical -> normal

messages: + msg369562
2020-05-21 06:23:11ned.deilysetmessages: + msg369500
2020-05-20 19:14:33IrvKalbsetmessages: + msg369468
2020-05-20 09:40:05ned.deilysetmessages: + msg369433
2020-05-20 09:25:24AndrewGYorksetmessages: + msg369432
2020-05-20 08:42:33ned.deilysetpriority: normal -> critical

messages: + msg369431
2020-05-20 06:46:51terry.reedysetmessages: + msg369420
2020-05-20 01:06:40IrvKalbsetnosy: + IrvKalb
messages: + msg369412
2020-04-22 07:13:55terry.reedysetmessages: + msg366983
2020-04-22 06:30:23AndrewGYorksetnosy: + AndrewGYork
messages: + msg366978
2019-11-30 23:52:56terry.reedysetnosy: + ronaldoussoren
messages: + msg357668
components: + macOS
2019-11-30 22:23:55ned.deilysettitle: IDLE not opening multiple .py files -> IDLE on macOS 10.15 Catalina does not open double-clicked files if app already launched
nosy: + ned.deily

messages: + msg357667

assignee: terry.reedy -> ned.deily
2019-11-30 19:10:41RMcreate