@@ -476,7 +476,8 @@ PyMac_Initialize(void)
476
476
#if TARGET_API_MAC_OSX /* Really: TARGET_API_MAC_CARBON */
477
477
478
478
static int
479
- locateResourcePy (char * resourceName , char * resourceURLCStr , int length ) {
479
+ locateResourcePy (CFStringRef resourceType , char * resourceName , char * resourceURLCStr , int length )
480
+ {
480
481
CFBundleRef mainBundle = NULL ;
481
482
CFURLRef URL , absoluteURL ;
482
483
CFStringRef filenameString , filepathString , rsrcString ;
@@ -500,7 +501,7 @@ locateResourcePy(char * resourceName, char * resourceURLCStr, int length) {
500
501
501
502
/* Look for py files in the main bundle by type */
502
503
arrayRef = CFBundleCopyResourceURLsOfType ( mainBundle ,
503
- CFSTR ( "py" ) ,
504
+ resourceType ,
504
505
NULL );
505
506
506
507
/* See if there are any filename matches */
@@ -541,18 +542,22 @@ main(int argc, char **argv)
541
542
/* First we see whether we have __rawmain__.py and run that if it
542
543
** is there
543
544
*/
544
- if (locateResourcePy ("__rawmain__.py" , scriptpath , 1024 )) {
545
+ if (locateResourcePy (CFSTR ( "py" ), "__rawmain__.py" , scriptpath , 1024 )) {
545
546
/* If we have a raw main we don't do AppleEvent processing.
546
547
** Notice that this also means we keep the -psn.... argv[1]
547
548
** value intact. Not sure whether that is important to someone,
548
549
** but you never know...
549
550
*/
550
551
script = scriptpath ;
552
+ } else if (locateResourcePy (CFSTR ("pyc" ), "__rawmain__.pyc" , scriptpath , 1024 )) {
553
+ script = scriptpath ;
551
554
} else {
552
555
/* Otherwise we look for __main__.py. Whether that is
553
556
** found or not we also process AppleEvent arguments.
554
557
*/
555
- if (locateResourcePy ("__main__.py" , scriptpath , 1024 ))
558
+ if (locateResourcePy (CFSTR ("py" ), "__main__.py" , scriptpath , 1024 ))
559
+ script = scriptpath ;
560
+ else if (locateResourcePy (CFSTR ("pyc" ), "__main__.pyc" , scriptpath , 1024 ))
556
561
script = scriptpath ;
557
562
558
563
init_common (& argc , & argv , 0 );
0 commit comments