diff options
Diffstat (limited to 'Modules/main.c')
-rw-r--r-- | Modules/main.c | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/Modules/main.c b/Modules/main.c index cebb17b..9e46717 100644 --- a/Modules/main.c +++ b/Modules/main.c @@ -135,6 +135,22 @@ Py_Main(int argc, char **argv) PySys_ResetWarnOptions(); +#if defined(WITH_NEXT_FRAMEWORK) + /* If we are running from a framework it could be that we are actually + ** the main program for an applet. If so, the next call will return the + ** filename that we are supposed to run. + */ + filename = PyMac_GetAppletScriptFile(); + if (filename != NULL) { + if ((fp = fopen(filename, "r")) == NULL) { + fprintf(stderr, "%s: can't open file '%s'\n", + argv[0], filename); + exit(2); + } + } + /* Skip option-processing if we are an applet */ + if (filename == NULL) +#endif while ((c = _PyOS_GetOpt(argc, argv, PROGRAM_OPTS)) != EOF) { if (c == 'c') { /* -c is the last option; following arguments @@ -261,7 +277,7 @@ Py_Main(int argc, char **argv) (p = Py_GETENV("PYTHONUNBUFFERED")) && *p != '\0') unbuffered = 1; - if (command == NULL && _PyOS_optind < argc && + if (command == NULL && filename == NULL && _PyOS_optind < argc && strcmp(argv[_PyOS_optind], "-") != 0) { filename = argv[_PyOS_optind]; |