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: PythonLauncher considered harmfull
Type: Stage:
Components: macOS Versions: Python 3.4
Status: open Resolution:
Dependencies: Superseder:
Assigned To: ronaldoussoren Nosy List: ezio.melotti, ned.deily, nirs, ronaldoussoren, wordtech
Priority: low Keywords:

Created on 2009-02-14 19:08 by ronaldoussoren, last changed 2022-04-11 14:56 by admin.

File name Uploaded Description Edit
issue-5262.txt ronaldoussoren, 2013-08-01 09:37 review
Messages (11)
msg82108 - (view) Author: Ronald Oussoren (ronaldoussoren) * (Python committer) Date: 2009-02-14 19:08
The Mac port of Python contains a binary named "PythonLauncher" which 
can be used as the association of ".py" and ".pyw" files. This program 
will launch the script (either in a Terminal window or without a 

In hindsight adding this tool was not a good idea: this makes it way to 
easy to accidently launch python script downloaded from the Internet. 
Removing PythonLauncher would still allow running the scripts through 
IDLE (which also has an association to ".py" and ".pyw" files in it 

In my experience most ".py" files are modules instead of standalone 
scripts, opening the file in an editor would therefore be a better 
action in the majority of use-cases.
msg90717 - (view) Author: Kevin Walzer (wordtech) * Date: 2009-07-20 01:01
I disagree that this is a bad idea--it's helpful to be able to double-
click a GUI script and launch it automatically. I realize one can just 
fire up Terminal and go "python," but I missed this 
functionality when it was broken and would be unhappy to see it removed.
msg90857 - (view) Author: Nir Soffer (nirs) * Date: 2009-07-23 19:04
I also think it should be removed. Opening a file should run it only if it 
is executable.
msg90858 - (view) Author: Ronald Oussoren (ronaldoussoren) * (Python committer) Date: 2009-07-23 19:11
At the very least PythonLauncher should not be the default for opening 
python files, and should actively warn against being the default 
(basicly reversing the current default).

When PythonLauncher is the default application for .py files double-
clicking a .py file, or opening it from will run the script. 
This is not what I'd expect when opening a source file and is risky when 
this happens accidently.

There are several ways for running python scripts by double-clicking on 
them. Two examples:

* Use py2app to create an .app bundle

* Give the script a ".command" suffix and a '#!/usr/bin/python' prefix.

Both result in "files" where it is clear that opening them will result 
in code execution.
msg100571 - (view) Author: Ronald Oussoren (ronaldoussoren) * (Python committer) Date: 2010-03-07 09:40
I propose to at least change the code in pythonlauncher to warn if it is the default association for python files, that is to reverse the test that it currently does.

That way users can still set pythonlauncher as the launcher for a specific files, but would get a warning when they make pythonlauncher the default action for python files.

BTW. I still think that pythonlauncher is unsafe and should be removed.
msg111988 - (view) Author: Ronald Oussoren (ronaldoussoren) * (Python committer) Date: 2010-07-29 19:20
Kevin: what's your opinion on changing PythonLauncher to check if it is the default action for opening python files and warning about that? 

What about refusing to run when Python Launcher is the default action for python files?

Users would still be able to run python files from the Finder by using the "Open with" menu, or by selecting Python Launcher through the Get Info dialog.

This would seriously reduce the risks w.r.t. accidentally running python scripts.

(Removing 2.7 because it is too late to change 2.7 behavior)
msg112035 - (view) Author: Kevin Walzer (wordtech) * Date: 2010-07-30 01:11

I'd vote for warning if it's the default action. 

Would your other proposed change require users to set PythonLauncher as the opening app for each Python file, or would there be a way to manually set it as the default from Finder or elsewhere? 

msg112040 - (view) Author: Ronald Oussoren (ronaldoussoren) * (Python committer) Date: 2010-07-30 05:56
> Would your other proposed change require users to set PythonLauncher as the opening app for each Python file, or would there be a way to manually set it as the default from Finder or elsewhere? 

I would no longer be possible to set PythonLauncher as the default action for Python files, because doing that is a clear security risk.

msg192565 - (view) Author: Ronald Oussoren (ronaldoussoren) * (Python committer) Date: 2013-07-07 14:42
I thinking about closing this issue, but need to do some more research before doing so. In particular, I need to check the behavior of double clicking on python files on Windows and the main Linux desktops. IIRC double clicking a .py file on Windows will execute that file, it might be useful to stay consistent with that and not disallow making Python Launcher the default action.
msg193685 - (view) Author: Ezio Melotti (ezio.melotti) * (Python committer) Date: 2013-07-25 03:32
FWIW more than once I tried to open a .py file on Windows just to see a black box flashing by and promptly disappear.  I agree that opening the file in an editor (e.g. IDLE) is a better option, but I realize some users might prefer to launch a script when they double-click on it (I always launch them by doing "python").
msg194039 - (view) Author: Ronald Oussoren (ronaldoussoren) * (Python committer) Date: 2013-08-01 09:37
The attached patch removes the code that checks if "Python Launcher" is the default application for opening python files.
Date User Action Args
2022-04-11 14:56:45adminsetgithub: 49512
2013-08-01 09:37:05ronaldoussorensetfiles: + issue-5262.txt

messages: + msg194039
2013-07-25 03:32:39ezio.melottisetnosy: + ezio.melotti
messages: + msg193685
2013-07-07 14:42:45ronaldoussorensetmessages: + msg192565
2013-07-07 11:21:34ronaldoussorensetpriority: normal -> low
versions: + Python 3.4, - Python 3.2
2013-07-07 11:19:17ronaldoussorensetfiles: - smime.p7s
2013-07-06 08:51:49ronaldoussorensetnosy: + ned.deily
2010-07-30 05:56:03ronaldoussorensetfiles: + smime.p7s

messages: + msg112040
2010-07-30 01:11:01wordtechsetmessages: + msg112035
2010-07-29 19:20:30ronaldoussorensetmessages: + msg111988
versions: - Python 2.7
2010-03-07 09:40:10ronaldoussorensetmessages: + msg100571
2009-07-23 19:11:46ronaldoussorensetmessages: + msg90858
versions: + Python 3.2, - Python 3.1
2009-07-23 19:04:11nirssetnosy: + nirs
messages: + msg90857
2009-07-20 01:01:05wordtechsetnosy: + wordtech
messages: + msg90717
2009-02-14 19:08:24ronaldoussorencreate