diff options
author | Jack Jansen <jack.jansen@cwi.nl> | 2002-03-29 14:43:50 (GMT) |
---|---|---|
committer | Jack Jansen <jack.jansen@cwi.nl> | 2002-03-29 14:43:50 (GMT) |
commit | 3cef721b61082d7f586afb9eee624fed65c594de (patch) | |
tree | 71b95168688f984405918c29c87905c21ed97cd7 /Mac/Python | |
parent | 5053b70da013a338a3a710875d94e811c95dee9d (diff) | |
download | cpython-3cef721b61082d7f586afb9eee624fed65c594de.zip cpython-3cef721b61082d7f586afb9eee624fed65c594de.tar.gz cpython-3cef721b61082d7f586afb9eee624fed65c594de.tar.bz2 |
Allow .pyc files as applets as well as .py files. .py files have
priority, for safety reasons.
Diffstat (limited to 'Mac/Python')
-rw-r--r-- | Mac/Python/macmain.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/Mac/Python/macmain.c b/Mac/Python/macmain.c index 02d0a82..cb6b331 100644 --- a/Mac/Python/macmain.c +++ b/Mac/Python/macmain.c @@ -476,7 +476,8 @@ PyMac_Initialize(void) #if TARGET_API_MAC_OSX /* Really: TARGET_API_MAC_CARBON */ static int -locateResourcePy(char * resourceName, char * resourceURLCStr, int length) { +locateResourcePy(CFStringRef resourceType, char *resourceName, char *resourceURLCStr, int length) +{ CFBundleRef mainBundle = NULL; CFURLRef URL, absoluteURL; CFStringRef filenameString, filepathString, rsrcString; @@ -500,7 +501,7 @@ locateResourcePy(char * resourceName, char * resourceURLCStr, int length) { /* Look for py files in the main bundle by type */ arrayRef = CFBundleCopyResourceURLsOfType( mainBundle, - CFSTR("py"), + resourceType, NULL ); /* See if there are any filename matches */ @@ -541,18 +542,22 @@ main(int argc, char **argv) /* First we see whether we have __rawmain__.py and run that if it ** is there */ - if (locateResourcePy("__rawmain__.py", scriptpath, 1024)) { + if (locateResourcePy(CFSTR("py"), "__rawmain__.py", scriptpath, 1024)) { /* If we have a raw main we don't do AppleEvent processing. ** Notice that this also means we keep the -psn.... argv[1] ** value intact. Not sure whether that is important to someone, ** but you never know... */ script = scriptpath; + } else if (locateResourcePy(CFSTR("pyc"), "__rawmain__.pyc", scriptpath, 1024)) { + script = scriptpath; } else { /* Otherwise we look for __main__.py. Whether that is ** found or not we also process AppleEvent arguments. */ - if (locateResourcePy("__main__.py", scriptpath, 1024)) + if (locateResourcePy(CFSTR("py"), "__main__.py", scriptpath, 1024)) + script = scriptpath; + else if (locateResourcePy(CFSTR("pyc"), "__main__.pyc", scriptpath, 1024)) script = scriptpath; init_common(&argc, &argv, 0); |