[Python-checkins] distutils/misc install.c,1.20,1.21

theller@users.sourceforge.net theller@users.sourceforge.net
Tue, 05 Nov 2002 02:02:08 -0800


Update of /cvsroot/python/distutils/misc
In directory usw-pr-cvs1:/tmp/cvs-serv10691a/misc

Modified Files:
	install.c 
Log Message:
Fixed the error handling of the run_installscript function.


Index: install.c
===================================================================
RCS file: /cvsroot/python/distutils/misc/install.c,v
retrieving revision 1.20
retrieving revision 1.21
diff -C2 -d -r1.20 -r1.21
*** install.c	16 Oct 2002 17:48:58 -0000	1.20
--- install.c	5 Nov 2002 10:02:03 -0000	1.21
***************
*** 328,345 ****
--- 328,359 ----
      char *name;
  } csidl_names[] = {
+     /* Startup menu for all users.
+        NT only */
      DEF_CSIDL(CSIDL_COMMON_STARTMENU),
+     /* Startup menu. */
      DEF_CSIDL(CSIDL_STARTMENU),
  
  /*    DEF_CSIDL(CSIDL_COMMON_APPDATA), */
  /*    DEF_CSIDL(CSIDL_LOCAL_APPDATA), */
+     /* Repository for application-specific data.
+        Needs Internet Explorer 4.0 */
      DEF_CSIDL(CSIDL_APPDATA),
  
+     /* The desktop for all users.
+        NT only */
      DEF_CSIDL(CSIDL_COMMON_DESKTOPDIRECTORY),
+     /* The desktop. */
      DEF_CSIDL(CSIDL_DESKTOPDIRECTORY),
  
+     /* Startup folder for all users.
+        NT only */
      DEF_CSIDL(CSIDL_COMMON_STARTUP),
+     /* Startup folder. */
      DEF_CSIDL(CSIDL_STARTUP),
  
+     /* Programs item in the start menu for all users.
+        NT only */
      DEF_CSIDL(CSIDL_COMMON_PROGRAMS),
+     /* Program item in the user's start menu. */
      DEF_CSIDL(CSIDL_PROGRAMS),
  
***************
*** 347,350 ****
--- 361,365 ----
  /*    DEF_CSIDL(CSIDL_PROGRAM_FILES), */
  
+     /* Virtual folder containing fonts. */
      DEF_CSIDL(CSIDL_FONTS),
  };
***************
*** 523,526 ****
--- 538,551 ----
  };
  
+ /*
+  * This function returns one of the following error codes:
+  * 1 if the Python-dll does not export the functions we need
+  * 2 if no install-script is specified in pathname
+  * 3 if the install-script file could not be opened
+  * the return value of PyRun_SimpleFile() otherwise,
+  * which is 0 if everything is ok, -1 if an exception had occurred
+  * in the install-script.
+  */
+ 
  static int run_installscript(HINSTANCE hPython, char *pathname, int argc, char **argv)
  {
***************
*** 543,557 ****
  
      if (!Py_Initialize || !PySys_SetArgv || !PyRun_SimpleFile || !Py_Finalize)
! 	return 0x80000000;
  
      if (!PyImport_ImportModule || !PyObject_SetAttrString || !Py_BuildValue)
! 	return 0x80000000;
  
      if (!PyCFunction_New || !PyArg_ParseTuple || !PyErr_Format)
! 	return 0x80000000;
  
      if (!PyObject_GetAttrString)
! 	return 0x80000000;
!     
  
      g_Py_BuildValue = Py_BuildValue;
--- 568,581 ----
  
      if (!Py_Initialize || !PySys_SetArgv || !PyRun_SimpleFile || !Py_Finalize)
! 	return 1;
  
      if (!PyImport_ImportModule || !PyObject_SetAttrString || !Py_BuildValue)
! 	return 1;
  
      if (!PyCFunction_New || !PyArg_ParseTuple || !PyErr_Format)
! 	return 1;
  
      if (!PyObject_GetAttrString)
! 	return 1;
  
      g_Py_BuildValue = Py_BuildValue;
***************
*** 560,568 ****
  
      if (pathname == NULL || pathname[0] == '\0')
! 	return 0x80000000;
  
      fp = fopen(pathname, "r");
      if (!fp) {
! 	return 0x80000000;
      }
  
--- 584,593 ----
  
      if (pathname == NULL || pathname[0] == '\0')
! 	return 2;
  
      fp = fopen(pathname, "r");
      if (!fp) {
! 	fprintf(stderr, "Could not open postinstall-script %s\n", pathname);
! 	return 3;
      }
  
***************
*** 1648,1654 ****
  	    hPython = LoadLibrary(pythondll);
  	    if (hPython) {
! 		if (0x80000000 == run_installscript(hPython, fname, 2, argv))
! 		    fprintf(stderr, "*** Could not load Python ***");
  		FreeLibrary(hPython);
  	    }
  	    fflush(stderr);
--- 1673,1684 ----
  	    hPython = LoadLibrary(pythondll);
  	    if (hPython) {
! 		int result;
! 		result = run_installscript(hPython, fname, 2, argv);
! 		if (result) {
! 		    fprintf(stderr, "*** run_installscript: internal error 0x%X ***\n", result);
! 		}
  		FreeLibrary(hPython);
+ 	    } else {
+ 		fprintf(stderr, "*** Could not load Python ***");
  	    }
  	    fflush(stderr);