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

Skip to content

Commit 0c6d037

Browse files
committed
Removed string-exception preference, added tabcheck and NavService preference, upped version number.
1 parent 1fdadcd commit 0c6d037

10 files changed

Lines changed: 52 additions & 13 deletions

File tree

Mac/Lib/pythonprefs.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,14 @@
1616
OVERRIDE_GUSI_ID = 10241
1717

1818
# version
19-
CUR_VERSION=4
19+
CUR_VERSION=5
2020

2121
preffilename = PstringLoader(AnyResLoader('STR ', resname=PREFNAME_NAME)).load()
2222
pref_fss = preferencefile(preffilename, 'Pyth', 'pref')
2323

2424
class PoptLoader(VersionLoader):
2525
def __init__(self, loader):
26-
VersionLoader.__init__(self, "bbbbbbbbbbbb", loader)
26+
VersionLoader.__init__(self, "bbbbbbbbbbbbb", loader)
2727

2828
def versioncheck(self, data):
2929
if data[0] == CUR_VERSION:
@@ -89,8 +89,8 @@ def load(self):
8989
flags = self.popt.load()
9090
dict['version'], dict['inspect'], dict['verbose'], dict['optimize'], \
9191
dict['unbuffered'], dict['debugging'], dict['keepopen'], dict['keeperror'], \
92-
dict['nointopt'], dict['noargs'], dict['oldexc'], \
93-
dict['nosite'] = flags
92+
dict['nointopt'], dict['noargs'], dict['tabwarn'], \
93+
dict['nosite'], dict['nonavservice'] = flags
9494
return dict
9595

9696
def save(self, dict):
@@ -100,8 +100,8 @@ def save(self, dict):
100100
self.gusi.save((dict['creator'], dict['type'], dict['delayconsole']))
101101
flags = dict['version'], dict['inspect'], dict['verbose'], dict['optimize'], \
102102
dict['unbuffered'], dict['debugging'], dict['keepopen'], dict['keeperror'], \
103-
dict['nointopt'], dict['noargs'], dict['oldexc'], \
104-
dict['nosite']
103+
dict['nointopt'], dict['noargs'], dict['tabwarn'], \
104+
dict['nosite'], dict['nonavservice']
105105
self.popt.save(flags)
106106

107107
def AppletOptions(file):

Mac/Python/macmain.c

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -149,8 +149,9 @@ PyMac_InteractiveOptions(PyMac_PrefRecord *p, int *argcp, char ***argvp)
149149
SET_OPT_ITEM(OPT_DEBUGGING, debugging);
150150
SET_OPT_ITEM(OPT_KEEPNORMAL, keep_normal);
151151
SET_OPT_ITEM(OPT_KEEPERROR, keep_error);
152-
SET_OPT_ITEM(OPT_OLDEXC, oldexc);
152+
SET_OPT_ITEM(OPT_TABWARN, tabwarn);
153153
SET_OPT_ITEM(OPT_NOSITE, nosite);
154+
SET_OPT_ITEM(OPT_NONAVSERV, nonavservice);
154155
/* The rest are not settable interactively */
155156

156157
#undef SET_OPT_ITEM
@@ -199,8 +200,9 @@ PyMac_InteractiveOptions(PyMac_PrefRecord *p, int *argcp, char ***argvp)
199200
OPT_ITEM(OPT_DEBUGGING, debugging);
200201
OPT_ITEM(OPT_KEEPNORMAL, keep_normal);
201202
OPT_ITEM(OPT_KEEPERROR, keep_error);
202-
OPT_ITEM(OPT_OLDEXC, oldexc);
203+
OPT_ITEM(OPT_TABWARN, tabwarn);
203204
OPT_ITEM(OPT_NOSITE, nosite);
205+
OPT_ITEM(OPT_NONAVSERV, nonavservice);
204206

205207
#undef OPT_ITEM
206208
}
@@ -266,7 +268,7 @@ init_common(int *argcp, char ***argvp, int embedded)
266268
Py_OptimizeFlag = options.optimize;
267269
Py_DebugFlag = options.debugging;
268270
Py_NoSiteFlag = options.nosite;
269-
Py_UseClassExceptionsFlag = !(options.oldexc);
271+
Py_TabcheckFlag = options.tabwarn;
270272
if ( options.noargs ) {
271273
/* don't process events at all without the scripts permission */
272274
PyMacSchedParams scp;
@@ -313,6 +315,30 @@ run_inspect()
313315
return sts;
314316
}
315317

318+
/*
319+
** Import the macfsn module, which will override the Standard File
320+
** calls in the macfs builtin module by Navigation Services versions,
321+
** if available on this machine.
322+
*/
323+
static void
324+
PyMac_InstallNavServicesForSF()
325+
{
326+
if ( !options.nonavservice ) {
327+
PyObject *m = PyImport_ImportModule("macfsn");
328+
329+
if ( m == NULL ) {
330+
PySys_WriteStderr("'import macfsn' failed; ");
331+
if (Py_VerboseFlag) {
332+
PySys_WriteStderr("traceback:\n");
333+
PyErr_Print();
334+
}
335+
else {
336+
PySys_WriteStderr("use -v for traceback\n");
337+
}
338+
}
339+
}
340+
}
341+
316342
#ifdef USE_MAC_APPLET_SUPPORT
317343
/* Applet support */
318344

@@ -360,6 +386,7 @@ PyMac_InitApplet()
360386
init_common(&argc, &argv, 0);
361387

362388
Py_Initialize();
389+
PyMac_InstallNavServicesForSF();
363390
PySys_SetArgv(argc, argv);
364391

365392
err = run_main_resource();
@@ -383,6 +410,7 @@ PyMac_Initialize()
383410

384411
init_common(&argc, &argv, 1);
385412
Py_Initialize();
413+
PyMac_InstallNavServicesForSF();
386414
PySys_SetArgv(argc, argv);
387415
}
388416

@@ -448,6 +476,8 @@ Py_Main(argc, argv)
448476

449477
Py_Initialize();
450478

479+
PyMac_InstallNavServicesForSF();
480+
451481
PySys_SetArgv(argc-1, argv+1);
452482

453483
if (filename == NULL && isatty((int)fileno(fp))) {

Mac/Resources/balloons.bh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@ DIALOG 231 Options
2020
13.3 Deselect to use new class-based standard exceptions.
2121
14.1 Selecting this disables the new package and site-python features.
2222
14.3 Deselecting this enables the new package and site-python features.
23-
16.1 Turn off balloon help.
23+
15.1 Turn off balloon help.
24+
16.1 Select this to keep the old behaviour for macfs Standard File calls
25+
16.3 Deselect this to auto-import macfsn which replaces macfs Standard File calls with Navigation Services wrappers
2426
END-DIALOG
2527
DIALOG 234
2628
1.1 Deleting the incorrect preference will not always work, but Python will run with standard options.

Mac/Resources/dialogs.rsrc

498 Bytes
Binary file not shown.

Mac/Resources/pythonpath.r

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ type 'Popt' {
2121
byte argcArgv = 0, noArgcArgv = 1;
2222
byte newStandardExceptions = 0, oldStandardExceptions = 1;
2323
byte sitePython = 0, noSitePython = 1;
24+
byte navService = 0, noNavService = 1;
2425
};
2526

2627
type 'TMPL' {
@@ -48,6 +49,7 @@ resource 'TMPL' (PYTHONOPTIONS_ID, "Popt") {
4849
"No argc/argv emulation", 'DBYT',
4950
"Old standard exceptions", 'DBYT',
5051
"No site-python support", 'DBYT',
52+
"No NavServices in macfs", 'DBYT',
5153
}
5254
};
5355

@@ -66,6 +68,7 @@ resource 'Popt' (PYTHONOPTIONS_ID, "Options") {
6668
argcArgv,
6769
newStandardExceptions,
6870
sitePython,
71+
navService,
6972
};
7073

7174
/* The sys.path initializer */

Mac/scripts/EditPythonPrefs.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,10 @@
4848
"noargs",
4949
"delayconsole",
5050
None, None, None, None, None, None, None, None, # 11-18 are different
51-
"oldexc",
52-
"nosite"]
51+
"tabwarn",
52+
"nosite",
53+
None,
54+
"nonavservices"]
5355
opt_dialog_dict = {}
5456
for i in range(len(opt_dialog_map)):
5557
if opt_dialog_map[i]:

Mac/scripts/EditPythonPrefs.rsrc

256 Bytes
Binary file not shown.

Mac/scripts/EditPythonPrefsBH.bh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ DIALOG 510
3636
19.3 Deselect to use new class-based standard exceptions.
3737
20.1 Selecting this disables the new package and site-python features.
3838
20.3 Deselecting this enables the new package and site-python features.
39-
22.1 Press here to turn help balloons off again.
39+
21.1 Press here to turn help balloons off again.
40+
22.1 Select this to use old-style Standard File calls in macfs
41+
22.3 Deselect this to auto-import macfsn which replaces macfs StandardFile calls with Navigation Services wrappers
4042
END-DIALOG
4143
END

Mac/scripts/EditPythonPrefsBH.prj

5.64 KB
Binary file not shown.

Mac/scripts/EditPythonPrefsBH.rsrc

196 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)