Patch from M.-A. Lemburg:
authorJeremy Hylton <jeremy@alum.mit.edu>
Fri, 26 May 2000 21:49:07 +0000 (21:49 +0000)
committerJeremy Hylton <jeremy@alum.mit.edu>
Fri, 26 May 2000 21:49:07 +0000 (21:49 +0000)
Python on UNIX now trusts PYTHONHOME unconditionally

Modules/getpath.c:

Landmark changed to os.py.

Setting PYTHONHOME now unconditionally sets sys.prefix
(and sys.exec_prefix). No further checks are done whether the
standard lib can be found in that location or not. This is in
sync with the PC subdir getpath implementations.

PC/getpathp.c:

Landmark changed to os.py.

PC/os2vacpp/getpathp.c:

Landmark changed to os.py.

Note: BAW's checkin on exceptions.c eliminates earlier concerns about
a bogus PYTHONHOME value leading to a core dump.  Instead it causes a
useless sys.path and prevents imports.

Modules/getpath.c
PC/getpathp.c
PC/os2vacpp/getpathp.c

index 7856813743cc3a25e623de16455d000001a9f11c..db37a1b83693dfb81379579256d63b11b7d02552 100644 (file)
@@ -87,7 +87,7 @@ PERFORMANCE OF THIS SOFTWARE.
  * Modules/Setup.  If the landmark is found, we're done.
  *
  * For the remaining steps, the prefix landmark will always be
- * lib/python$VERSION/string.py and the exec_prefix will always be
+ * lib/python$VERSION/os.py and the exec_prefix will always be
  * lib/python$VERSION/lib-dynload, where $VERSION is Python's version
  * number as supplied by the Makefile.  Note that this means that no more
  * build directory checking is performed; if the first step did not find
@@ -150,7 +150,7 @@ PERFORMANCE OF THIS SOFTWARE.
 #endif
 
 #ifndef LANDMARK
-#define LANDMARK "string.py"
+#define LANDMARK "os.py"
 #endif
 
 static char prefix[MAXPATHLEN+1];
@@ -265,6 +265,18 @@ search_for_prefix(argv0_path, home)
        int n;
        char *vpath;
 
+       /* If PYTHONHOME is set, we believe it unconditionally */
+       if (home) {
+               char *delim;
+               strcpy(prefix, home);
+               delim = strchr(prefix, DELIM);
+               if (delim)
+                       *delim = '\0';
+               joinpath(prefix, lib_python);
+               joinpath(prefix, LANDMARK);
+               return 1;
+       }
+
        /* Check to see if argv[0] is in the build directory */
        strcpy(prefix, argv0_path);
        joinpath(prefix, "Modules/Setup");
@@ -290,19 +302,6 @@ search_for_prefix(argv0_path, home)
                        return -1;
        }
 
-       if (home) {
-               /* Check $PYTHONHOME */
-               char *delim;
-               strcpy(prefix, home);
-               delim = strchr(prefix, DELIM);
-               if (delim)
-                       *delim = '\0';
-               joinpath(prefix, lib_python);
-               joinpath(prefix, LANDMARK);
-               if (ismodule(prefix))
-                       return 1;
-       }
-
        /* Search from argv0_path, until root is found */
        strcpy(prefix, argv0_path);
        do {
@@ -334,16 +333,8 @@ search_for_exec_prefix(argv0_path, home)
 {
        int n;
 
-       /* Check to see if argv[0] is in the build directory */
-       strcpy(exec_prefix, argv0_path);
-       joinpath(exec_prefix, "Modules/Setup");
-       if (isfile(exec_prefix)) {
-               reduce(exec_prefix);
-               return -1;
-       }
-
+       /* If PYTHONHOME is set, we believe it unconditionally */
        if (home) {
-               /* Check $PYTHONHOME */
                char *delim;
                delim = strchr(home, DELIM);
                if (delim)
@@ -352,10 +343,17 @@ search_for_exec_prefix(argv0_path, home)
                        strcpy(exec_prefix, home);
                joinpath(exec_prefix, lib_python);
                joinpath(exec_prefix, "lib-dynload");
-               if (isdir(exec_prefix))
                        return 1;
        }
 
+       /* Check to see if argv[0] is in the build directory */
+       strcpy(exec_prefix, argv0_path);
+       joinpath(exec_prefix, "Modules/Setup");
+       if (isfile(exec_prefix)) {
+               reduce(exec_prefix);
+               return -1;
+       }
+
        /* Search from argv0_path, until root is found */
        strcpy(exec_prefix, argv0_path);
        do {
index 2123b2a76c6febe3c763c1de5048d5c137c970d2..4354853522f530f788400f81ddbfc946ec312d80 100644 (file)
@@ -53,7 +53,7 @@ PERFORMANCE OF THIS SOFTWARE.
 
    * We attempt to locate the "Python Home" - if the PYTHONHOME env var
      is set, we believe it.  Otherwise, we use the path of our host .EXE's
-     to try and locate our "landmark" (lib\\string.py) and deduce our home.
+     to try and locate our "landmark" (lib\\os.py) and deduce our home.
      - If we DO have a Python Home: The relevant sub-directories (Lib, 
        plat-win, lib-tk, etc) are based on the Python Home
      - If we DO NOT have a Python Home, the core Python Path is
@@ -110,7 +110,7 @@ PERFORMANCE OF THIS SOFTWARE.
  */
 
 #ifndef LANDMARK
-#define LANDMARK "lib\\string.py"
+#define LANDMARK "lib\\os.py"
 #endif
 
 static char prefix[MAXPATHLEN+1];
index b7056ab1b401b2c899a7f7a4515748378b4d0cf7..a4a4d0efba3a0df8aaae05af82b657352ca851cc 100644 (file)
@@ -68,14 +68,14 @@ extern BOOL PyWin_IsWin32s();
  *
  * Otherwise, if there is a PYTHONPATH environment variable, we return that.
  *
- * Otherwise we try to find $progpath/lib/string.py, and if found, then
+ * Otherwise we try to find $progpath/lib/os.py, and if found, then
  * root is $progpath/lib, and we return Python path as compiled PYTHONPATH
  * with all "./lib" replaced by $root (as above).
  *
  */
 
 #ifndef LANDMARK
-#define LANDMARK "lib\\string.py"
+#define LANDMARK "lib\\os.py"
 #endif
 
 static char prefix[MAXPATHLEN+1];