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

Skip to content

Commit 45ff77f

Browse files
committed
- The prefs file wasn't updated correctly if it already existed.
- Guido's r1.23 fix wrt PyMac_DoYieldEnabled had somehow gotten lost.
1 parent e08dea1 commit 45ff77f

1 file changed

Lines changed: 10 additions & 5 deletions

File tree

Mac/Python/macglue.c

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,7 @@ PyMac_GetPythonDir()
400400
static char name[256];
401401
AliasHandle handle;
402402
FSSpec dirspec;
403-
int ok = 0, exists = 0;
403+
int ok = 0;
404404
Boolean modified = 0, cannotmodify = 0;
405405
short oldrh, prefrh;
406406
short prefdirRefNum;
@@ -425,6 +425,7 @@ PyMac_GetPythonDir()
425425
FSpCreateResFile(&dirspec, 'PYTH', 'pref', 0);
426426
prefrh = FSpOpenResFile(&dirspec, fsRdWrShPerm);
427427
if ( prefrh == -1 ) {
428+
/* This is strange, what should we do now? */
428429
cannotmodify = 1;
429430
} else {
430431
UseResFile(prefrh);
@@ -435,9 +436,9 @@ PyMac_GetPythonDir()
435436
handle = (AliasHandle)Get1Resource('alis', 128);
436437
if ( handle ) {
437438
/* It exists. Resolve it (possibly updating it) */
438-
if ( ResolveAlias(NULL, handle, &dirspec, &modified) == noErr )
439+
if ( ResolveAlias(NULL, handle, &dirspec, &modified) == noErr ) {
439440
ok = 1;
440-
exists = 1;
441+
}
441442
}
442443
if ( !ok ) {
443444
/* No luck, so far. ask the user for help */
@@ -456,10 +457,14 @@ PyMac_GetPythonDir()
456457
}
457458
}
458459
}
460+
if ( handle ) {
461+
/* Set the (old, invalid) alias record to the new data */
462+
UpdateAlias(NULL, &dirspec, handle, &modified);
463+
}
459464
}
460465
if ( ok && modified && !cannotmodify) {
461466
/* We have a new, valid fsspec and we can update the preferences file. Do so. */
462-
if ( !exists ) {
467+
if ( !handle ) {
463468
if (NewAlias(NULL, &dirspec, &handle) == 0 )
464469
AddResource((Handle)handle, 'alis', 128, "\p");
465470
} else {
@@ -879,9 +884,9 @@ PyMac_InitApplication()
879884
endp = strrchr(curwd, ':');
880885
if ( endp && endp > curwd ) {
881886
*endp = '\0';
887+
882888
chdir(curwd);
883889
}
884890
}
885891
Py_Main(argc, argv);
886892
}
887-

0 commit comments

Comments
 (0)