Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 48a9c36

Browse files
committed
Mods by Just to allow aliases in sys.path entries
1 parent 9819983 commit 48a9c36

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

Mac/Python/macimport.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
4848
#endif
4949
#include <CodeFragments.h>
5050

51+
#ifdef USE_GUSI
52+
#include "TFileSpec.h" /* for Path2FSSpec() */
53+
#endif
54+
5155
typedef void (*dl_funcptr)();
5256
#define FUNCNAME_PATTERN "init%.200s"
5357

@@ -100,7 +104,11 @@ findnamedresource(
100104
UseResFile(PyMac_AppRefNum);
101105
filerh = -1;
102106
} else {
107+
#ifdef USE_GUSI
108+
if ( Path2FSSpec(filename, &fss) != noErr ||
109+
#else
103110
if ( FSMakeFSSpec(0, 0, Pstring(filename), &fss) != noErr ||
111+
#endif
104112
FSpGetFInfo(&fss, &finfo) != noErr ) {
105113
#ifdef INTERN_STRINGS
106114
if ( obj && max_not_a_file < MAXPATHCOMPONENTS && obj->ob_sinterned )
@@ -296,7 +304,12 @@ char *filename;
296304
UseResFile(PyMac_AppRefNum);
297305
filerh = -1;
298306
} else {
307+
#ifdef USE_GUSI
308+
if ( (err=Path2FSSpec(filename, &fss)) != noErr ||
309+
FSpGetFInfo(&fss, &finfo) != noErr )
310+
#else
299311
if ( (err=FSMakeFSSpec(0, 0, Pstring(filename), &fss)) != noErr )
312+
#endif
300313
goto error;
301314
if ( (err=FSpGetFInfo(&fss, &finfo)) != noErr )
302315
goto error;
@@ -401,6 +414,7 @@ PyMac_FindModuleExtension(char *buf, int *lenp, char *module)
401414
unsigned char fnbuf[64];
402415
int modnamelen = strlen(module);
403416
FSSpec fss;
417+
FInfo finfo;
404418
short refnum;
405419
long dirid;
406420

@@ -419,8 +433,14 @@ PyMac_FindModuleExtension(char *buf, int *lenp, char *module)
419433
#else
420434
strcpy(buf+*lenp, _PyImport_Filetab[0].suffix);
421435
#endif
436+
#ifdef USE_GUSI
437+
if ( Path2FSSpec(buf, &fss) == noErr &&
438+
FSpGetFInfo(&fss, &finfo) == noErr)
439+
return _PyImport_Filetab;
440+
#else
422441
if ( FSMakeFSSpec(0, 0, Pstring(buf), &fss) == noErr )
423442
return _PyImport_Filetab;
443+
#endif
424444
/*
425445
** We cannot check for fnfErr (unfortunately), it can mean either that
426446
** the file doesn't exist (fine, we try others) or the path leading to it.

0 commit comments

Comments
 (0)