]> granicus.if.org Git - python/commitdiff
- sys.path[0] (the directory from which the script is loaded) is now
authorGuido van Rossum <guido@python.org>
Wed, 19 Feb 2003 15:25:10 +0000 (15:25 +0000)
committerGuido van Rossum <guido@python.org>
Wed, 19 Feb 2003 15:25:10 +0000 (15:25 +0000)
  turned into an absolute pathname, unless it is the empty string.
  (SF patch #664376, by Skip Montanaro.)

Misc/NEWS
Python/sysmodule.c
configure
configure.in
pyconfig.h.in

index 8671650bc53831e0efa99080582c74cef8415be0..7198541a2ab402abe8e06e68e3083f23673875ff 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -12,6 +12,10 @@ What's New in Python 2.3 alpha 2?
 Core and builtins
 -----------------
 
+- sys.path[0] (the directory from which the script is loaded) is now
+  turned into an absolute pathname, unless it is the empty string.
+  (SF patch #664376.)
+
 - Finally fixed the bug in compile() and exec where a string ending
   with an indented code block but no newline would raise SyntaxError.
   This would have been a four-line change in parsetok.c...  Except
index 765621ecdb515ab1412eb2c942a26dbd74876460..1f51f988f9e8abd317c971527523441a3c669266 100644 (file)
@@ -993,7 +993,9 @@ makeargvobject(int argc, char **argv)
 void
 PySys_SetArgv(int argc, char **argv)
 {
-#ifdef MS_WINDOWS
+#if defined(HAVE_REALPATH)
+       char fullpath[MAXPATHLEN];
+#elif defined(MS_WINDOWS)
        char fullpath[MAX_PATH];
 #endif
        PyObject *av = makeargvobject(argc, argv);
@@ -1059,8 +1061,14 @@ PySys_SetArgv(int argc, char **argv)
                        }
                }
 #else /* All other filename syntaxes */
-               if (argc > 0 && argv0 != NULL)
+               if (argc > 0 && argv0 != NULL) {
+#if defined(HAVE_REALPATH)
+                       if (realpath(argv0, fullpath)) {
+                               argv0 = fullpath;
+                       }
+#endif
                        p = strrchr(argv0, SEP);
+               }
                if (p != NULL) {
 #ifndef RISCOS
                        n = p + 1 - argv0;
index e0837f7a7a558bd37543938886dcd89d2696758f..1dfc8bc175649814254968995e53bee3d9fd0e32 100755 (executable)
--- a/configure
+++ b/configure
@@ -1,5 +1,5 @@
 #! /bin/sh
-# From configure.in Revision: 1.387 .
+# From configure.in Revision: 1.389 .
 # Guess values for system-dependent variables and create Makefiles.
 # Generated by GNU Autoconf 2.53 for python 2.3.
 #
@@ -12093,6 +12093,7 @@ echo "${ECHO_T}MACHDEP_OBJS" >&6
 
 
 
+
 
 
 for ac_func in alarm chown clock confstr ctermid execv \
@@ -12101,7 +12102,7 @@ for ac_func in alarm chown clock confstr ctermid execv \
  getpriority getpwent getwd \
  hstrerror inet_aton inet_pton kill killpg lchown lstat mkfifo mknod mktime \
  mremap nice pathconf pause plock poll pthread_init \
- putenv readlink \
+ putenv readlink realpath \
  select setegid seteuid setgid \
  setlocale setregid setreuid setsid setpgid setuid setvbuf snprintf \
  sigaction siginterrupt sigrelse strftime strptime \
index 8fce1cd9be0cec0da473c7e7747b03452bf51a41..0b893a5c36a40e24ed5acb0763a37ffdadb5aec9 100644 (file)
@@ -1843,7 +1843,7 @@ AC_CHECK_FUNCS(alarm chown clock confstr ctermid execv \
  getpriority getpwent getwd \
  hstrerror inet_aton inet_pton kill killpg lchown lstat mkfifo mknod mktime \
  mremap nice pathconf pause plock poll pthread_init \
- putenv readlink \
+ putenv readlink realpath \
  select setegid seteuid setgid \
  setlocale setregid setreuid setsid setpgid setuid setvbuf snprintf \
  sigaction siginterrupt sigrelse strftime strptime \
index c1697975bf5f38abc4da9550ec46e661352ceb89..e2dd4d28ec5f635d75075457e6dc98005112f493 100644 (file)
 /* Define to 1 if you have the `readlink' function. */
 #undef HAVE_READLINK
 
+/* Define to 1 if you have the `realpath' function. */
+#undef HAVE_REALPATH
+
 /* Define if you have readline 2.2 */
 #undef HAVE_RL_COMPLETION_APPEND_CHARACTER