[Python-checkins] CVS: python/dist/src/Modules getpath.c,1.21,1.22

Jeremy Hylton python-dev@python.org
Fri, 26 May 2000 14:49:09 -0700


Update of /cvsroot/python/python/dist/src/Modules
In directory slayer.i.sourceforge.net:/tmp/cvs-serv11753/Modules

Modified Files:
	getpath.c 
Log Message:
Patch from M.-A. Lemburg:
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.



Index: getpath.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Modules/getpath.c,v
retrieving revision 1.21
retrieving revision 1.22
diff -C2 -r1.21 -r1.22
*** getpath.c	2000/05/03 23:44:32	1.21
--- getpath.c	2000/05/26 21:49:07	1.22
***************
*** 88,92 ****
   *
   * 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/lib-dynload, where $VERSION is Python's version
   * number as supplied by the Makefile.  Note that this means that no more
--- 88,92 ----
   *
   * For the remaining steps, the prefix landmark 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
***************
*** 151,155 ****
  
  #ifndef LANDMARK
! #define LANDMARK "string.py"
  #endif
  
--- 151,155 ----
  
  #ifndef LANDMARK
! #define LANDMARK "os.py"
  #endif
  
***************
*** 266,269 ****
--- 266,281 ----
  	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);
***************
*** 291,307 ****
  	}
  
- 	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);
--- 303,306 ----
***************
*** 335,348 ****
  	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 (home) {
- 		/* Check $PYTHONHOME */
  		char *delim;
  		delim = strchr(home, DELIM);
--- 334,339 ----
  	int n;
  
! 	/* If PYTHONHOME is set, we believe it unconditionally */
  	if (home) {
  		char *delim;
  		delim = strchr(home, DELIM);
***************
*** 353,358 ****
  		joinpath(exec_prefix, lib_python);
  		joinpath(exec_prefix, "lib-dynload");
- 		if (isdir(exec_prefix))
  			return 1;
  	}
  
--- 344,356 ----
  		joinpath(exec_prefix, lib_python);
  		joinpath(exec_prefix, "lib-dynload");
  			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;
  	}