New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Is Preferences window supposed to stay open on Python Launcher? #113718
Comments
Thanks for your query. I believe that behavior is by design. It allows the user to have some control over the behavior of the execution of the Python file. Despite that, there are security concerns with the Python Launcher app provided for macOS, as noted in #49512, for example. Not opening the preferences window could make it easier for stealth execution of "bad actor" scripts. The Launcher app itself is very old and is need of a redesign. Until that happens, I don't there will be any change in the current behavior. |
AFAIK this behaviour is not intentional, but Python Launcher depends on the order of system events during startup and those (appearently) have changed. See the code below that suggests that the launcher should stop immediately when opening an event. cpython/Mac/PythonLauncher/MyAppDelegate.m Lines 21 to 44 in 0ae60b6
As Ned writes the code is old and needs some love. |
A very rough patch that gives slightly better behaviour: diff --git a/Mac/PythonLauncher/MyAppDelegate.m b/Mac/PythonLauncher/MyAppDelegate.m
index 9cc2aa0ad9..51934d4e0e 100644
--- a/Mac/PythonLauncher/MyAppDelegate.m
+++ b/Mac/PythonLauncher/MyAppDelegate.m
@@ -25,10 +25,12 @@ - (void)applicationDidFinishLaunching:(NSNotification *)notification
// If we were opened because of a file drag or double-click
// we've set initial_action_done in shouldShowUI
// Otherwise we open a preferences dialog.
+#if 0
if (!initial_action_done) {
initial_action_done = YES;
[self showPreferences: self];
}
+#endif
}
- (BOOL)shouldShowUI
@@ -50,6 +52,10 @@ - (BOOL)shouldTerminate
- (BOOL)applicationShouldOpenUntitledFile:(NSApplication *)sender
{
+ if (!initial_action_done) {
+ initial_action_done = YES;
+ [self showPreferences: self];
+ }
return NO;
} With the patch:
This still relies on an unspecified order of events, but should be safer: The new code hooks into the document-based app code to show the preference pane when AppKit tries to decide if it should show a new "Untitled" document (which means there weren't file-open events). There's no PR yet because I haven't properly tested yet (including tests with an installed copy of the launcher and through the Finder), and because I want to look into what happens when you try to open more than one script at once. I'll likely add a Read Me as well that fully documents how to app is supposed to work, and how to test it (manually). |
Sounds much cleaner. When there is a build with this mod I can test on Ventura and Sonoma, Intel and Apple Silicon. Thank you! |
Bug report
Bug description:
possible bug...?
The preferences window remains open when you double-click a ".py" file in Finder on MacOS. This is with no options selected in preferences (such as run in terminal window).
I would have expected a flag for silent operation or for the window to automatically close instead of hovering in the middle of the screen.
CPython versions tested on:
3.13
Operating systems tested on:
macOS
The text was updated successfully, but these errors were encountered: