]> granicus.if.org Git - python/commitdiff
Moved macfsn hackery from macmain.c to macfsmodule.c so it loads
authorJust van Rossum <just@letterror.com>
Wed, 31 Oct 2001 22:55:08 +0000 (22:55 +0000)
committerJust van Rossum <just@letterror.com>
Wed, 31 Oct 2001 22:55:08 +0000 (22:55 +0000)
on demand instead of at startup.

Mac/Modules/macfsmodule.c
Mac/Python/macmain.c

index 15d9f30857d50838bdbb815c32b681d64c197c27..f16cd363dc7626c6a1592ae8a3a585486e713670 100644 (file)
@@ -39,6 +39,9 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 
 #include "getapplbycreator.h"
 
+#include "pythonresources.h"
+extern PyMac_PrefRecord PyMac_options;
+
 #ifdef USE_TOOLBOX_OBJECT_GLUE
 extern int _PyMac_GetFSSpec(PyObject *, FSSpec *);
 extern PyObject *_PyMac_BuildFSSpec(FSSpec *);
@@ -1206,6 +1209,33 @@ PyObject *PyMac_BuildFSSpec(FSSpec *v)
        return (PyObject *)newmfssobject(v);
 }
 
+
+/*
+** Import the macfsn module, which will override the Standard File
+** calls in the macfs builtin module by Navigation Services versions,
+** if available on this machine.
+*/
+static void
+PyMac_InstallNavServicesForSF(void)
+{
+       if ( !PyMac_options.nonavservice ) {
+               PyObject *m = PyImport_ImportModule("macfsn");
+               
+               if ( m == NULL ) {
+                       PySys_WriteStderr("'import macfsn' failed; ");
+                       if (Py_VerboseFlag) {
+                               PySys_WriteStderr("traceback:\n");
+                               PyErr_Print();
+                       }
+                       else {
+                               PySys_WriteStderr("use -v for traceback\n");
+                       }
+                       PyErr_Clear();
+               }
+       }
+}
+
+
 /* Initialization function for the module (*must* be called initmacfs) */
 
 void
@@ -1235,5 +1265,6 @@ initmacfs(void)
        Mfsitype.ob_type = &PyType_Type;
        Py_INCREF(&Mfsitype);
        PyDict_SetItemString(d, "FInfoType", (PyObject *)&Mfsitype);
-       /* XXXX Add constants here */
+
+       PyMac_InstallNavServicesForSF();
 }
index ad0d82b6a63cd7079dd028a4ef6d091ff65666fa..b86b52847fc6eabc2c6f6e1abc2a52760113af58 100644 (file)
@@ -392,31 +392,6 @@ run_inspect(void)
        return sts;
 }
        
-/*
-** Import the macfsn module, which will override the Standard File
-** calls in the macfs builtin module by Navigation Services versions,
-** if available on this machine.
-*/
-static void
-PyMac_InstallNavServicesForSF(void)
-{
-       if ( !PyMac_options.nonavservice ) {
-               PyObject *m = PyImport_ImportModule("macfsn");
-               
-               if ( m == NULL ) {
-                       PySys_WriteStderr("'import macfsn' failed; ");
-                       if (Py_VerboseFlag) {
-                               PySys_WriteStderr("traceback:\n");
-                               PyErr_Print();
-                       }
-                       else {
-                               PySys_WriteStderr("use -v for traceback\n");
-                       }
-                       PyErr_Clear();
-               }
-       }
-}
-
 #ifdef USE_MAC_APPLET_SUPPORT
 /* Applet support */
 
@@ -464,7 +439,6 @@ PyMac_InitApplet(void)
        init_common(&argc, &argv, 0);
        
        Py_Initialize();
-       PyMac_InstallNavServicesForSF();
        PySys_SetArgv(argc, argv);
        
        err = run_main_resource();
@@ -488,7 +462,6 @@ PyMac_Initialize(void)
        
        init_common(&argc, &argv, 1);
        Py_Initialize();
-       PyMac_InstallNavServicesForSF();
        PySys_SetArgv(argc, argv);
 }
 
@@ -675,8 +648,6 @@ Py_Main(int argc, char **argv, char *filename)
        
        PyUnicode_SetDefaultEncoding(PyMac_getscript());
        
-       PyMac_InstallNavServicesForSF();
-
        PySys_SetArgv(argc, argv);
 
        if (filename == NULL && isatty((int)fileno(fp))) {