patch mentioned in the changelog...

This commit is contained in:
Peter Jones 2005-09-25 20:55:14 +00:00
parent c2cc4f3abd
commit 780b6f017c
1 changed files with 40 additions and 37 deletions

View File

@ -1,5 +1,17 @@
--- Python-2.4.1/pyconfig.h.in.canonicalize 2004-10-13 11:30:55.000000000 -0400
+++ Python-2.4.1/pyconfig.h.in 2005-09-25 16:30:43.000000000 -0400
@@ -58,6 +58,9 @@
/* Define if pthread_sigmask() does not work on your system. */
#undef HAVE_BROKEN_PTHREAD_SIGMASK
+/* Define to 1 if you have the `canonicalize_file_name' function. */
+#undef HAVE_CANONICALIZE_FILE_NAME
+
/* Define to 1 if you have the `chown' function. */
#undef HAVE_CHOWN
--- Python-2.4.1/Python/sysmodule.c.canonicalize 2005-01-27 13:58:30.000000000 -0500 --- Python-2.4.1/Python/sysmodule.c.canonicalize 2005-01-27 13:58:30.000000000 -0500
+++ Python-2.4.1/Python/sysmodule.c 2005-09-23 17:18:33.000000000 -0400 +++ Python-2.4.1/Python/sysmodule.c 2005-09-25 16:38:47.000000000 -0400
@@ -1168,11 +1168,13 @@ @@ -1168,11 +1168,13 @@
void void
PySys_SetArgv(int argc, char **argv) PySys_SetArgv(int argc, char **argv)
@ -14,39 +26,41 @@
PyObject *av = makeargvobject(argc, argv); PyObject *av = makeargvobject(argc, argv);
PyObject *path = PySys_GetObject("path"); PyObject *path = PySys_GetObject("path");
if (av == NULL) if (av == NULL)
@@ -1184,6 +1186,31 @@ @@ -1184,6 +1186,33 @@
char *p = NULL; char *p = NULL;
int n = 0; int n = 0;
PyObject *a; PyObject *a;
+#ifdef HAVE_CANONICALIZE_FILE_NAME +#ifdef HAVE_CANONICALIZE_FILE_NAME
+ int errnum; + int errnum;
+ +
+ if (argv[0][0] == '\0') + if (argc > 0 && argv0 != NULL) {
+ /* python started with no arguments + if (argv[0][0] == '\0')
+ copy the empty string and move on */ + /* python started with no arguments
+ argv0 = strdup(argv[0]); + copy the empty string and move on */
+ else { + argv0 = strdup(argv[0]);
+ argv0 = canonicalize_file_name(argv[0]); + else {
+ errnum = errno; + argv0 = canonicalize_file_name(argv[0]);
+ if (argv0 == NULL) { + errnum = errno;
+ if (errnum != ENOENT) + if (argv0 == NULL) {
+ Py_FatalError(strerror(errnum)); + if (errnum != ENOENT)
+ Py_FatalError(strerror(errnum));
+ +
+ /* errnum == ENOENT; the input file name is empty, or + /* errno == ENOENT; the input file name is
+ * at least one of the path components does not exist + empty, or at least one of the path
+ * */ + components does not exist */
+ /* strdup because we're going to free() it + /* strdup because we're going to free() it
+ later no matter what */ + later no matter what */
+ argv0 = strdup(argv[0]); + argv0 = strdup(argv[0]);
+ if (argv0 == NULL) + }
+ Py_FatalError("no mem for sys.argv"); + }
+ } + if (argv0 == NULL)
+ } + Py_FatalError("no mem for sys.argv");
+ }
+#else /* ! HAVE_CANONICALIZE_FILE_NAME */ +#else /* ! HAVE_CANONICALIZE_FILE_NAME */
#ifdef HAVE_READLINK #ifdef HAVE_READLINK
char link[MAXPATHLEN+1]; char link[MAXPATHLEN+1];
char argv0copy[2*MAXPATHLEN+1]; char argv0copy[2*MAXPATHLEN+1];
@@ -1256,9 +1283,13 @@ @@ -1256,9 +1285,14 @@
#endif /* Unix */ #endif /* Unix */
} }
#endif /* All others */ #endif /* All others */
@ -55,13 +69,14 @@
if (a == NULL) if (a == NULL)
Py_FatalError("no mem for sys.path insertion"); Py_FatalError("no mem for sys.path insertion");
+#ifdef HAVE_CANONICALIZE_FILE_NAME +#ifdef HAVE_CANONICALIZE_FILE_NAME
+ free(argv0); + if (argv0)
+ free(argv0);
+#endif /* HAVE_CANONICALIZE_FILE_NAME */ +#endif /* HAVE_CANONICALIZE_FILE_NAME */
if (PyList_Insert(path, 0, a) < 0) if (PyList_Insert(path, 0, a) < 0)
Py_FatalError("sys.path.insert(0) failed"); Py_FatalError("sys.path.insert(0) failed");
Py_DECREF(a); Py_DECREF(a);
--- Python-2.4.1/configure.in.canonicalize 2005-03-28 18:23:34.000000000 -0500 --- Python-2.4.1/configure.in.canonicalize 2005-03-28 18:23:34.000000000 -0500
+++ Python-2.4.1/configure.in 2005-09-23 17:19:14.000000000 -0400 +++ Python-2.4.1/configure.in 2005-09-25 16:30:43.000000000 -0400
@@ -2096,8 +2096,8 @@ @@ -2096,8 +2096,8 @@
AC_MSG_RESULT(MACHDEP_OBJS) AC_MSG_RESULT(MACHDEP_OBJS)
@ -73,15 +88,3 @@
gai_strerror getgroups getlogin getloadavg getpeername getpgid getpid \ gai_strerror getgroups getlogin getloadavg getpeername getpgid getpid \
getpriority getpwent getsid getwd \ getpriority getpwent getsid getwd \
kill killpg lchown lstat mkfifo mknod mktime \ kill killpg lchown lstat mkfifo mknod mktime \
--- Python-2.4.1/pyconfig.h.in.canonicalize 2004-10-13 11:30:55.000000000 -0400
+++ Python-2.4.1/pyconfig.h.in 2005-09-23 17:19:14.000000000 -0400
@@ -58,6 +58,9 @@
/* Define if pthread_sigmask() does not work on your system. */
#undef HAVE_BROKEN_PTHREAD_SIGMASK
+/* Define to 1 if you have the `canonicalize_file_name' function. */
+#undef HAVE_CANONICALIZE_FILE_NAME
+
/* Define to 1 if you have the `chown' function. */
#undef HAVE_CHOWN