comparison Python/sysmodule.c @ 27977:0fe321e78ad3 legacy-trunk

- 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, by Skip Montanaro.)
author Guido van Rossum <guido@python.org>
date Wed, 19 Feb 2003 15:25:10 +0000
parents 16856c9514e0
children 869695cba2cd
comparison
equal deleted inserted replaced
27976:d5ea2b67b5f4 27977:0fe321e78ad3
991 } 991 }
992 992
993 void 993 void
994 PySys_SetArgv(int argc, char **argv) 994 PySys_SetArgv(int argc, char **argv)
995 { 995 {
996 #ifdef MS_WINDOWS 996 #if defined(HAVE_REALPATH)
997 char fullpath[MAXPATHLEN];
998 #elif defined(MS_WINDOWS)
997 char fullpath[MAX_PATH]; 999 char fullpath[MAX_PATH];
998 #endif 1000 #endif
999 PyObject *av = makeargvobject(argc, argv); 1001 PyObject *av = makeargvobject(argc, argv);
1000 PyObject *path = PySys_GetObject("path"); 1002 PyObject *path = PySys_GetObject("path");
1001 if (av == NULL) 1003 if (av == NULL)
1057 if (n > 1 && p[-1] != ':') 1059 if (n > 1 && p[-1] != ':')
1058 n--; /* Drop trailing separator */ 1060 n--; /* Drop trailing separator */
1059 } 1061 }
1060 } 1062 }
1061 #else /* All other filename syntaxes */ 1063 #else /* All other filename syntaxes */
1062 if (argc > 0 && argv0 != NULL) 1064 if (argc > 0 && argv0 != NULL) {
1065 #if defined(HAVE_REALPATH)
1066 if (realpath(argv0, fullpath)) {
1067 argv0 = fullpath;
1068 }
1069 #endif
1063 p = strrchr(argv0, SEP); 1070 p = strrchr(argv0, SEP);
1071 }
1064 if (p != NULL) { 1072 if (p != NULL) {
1065 #ifndef RISCOS 1073 #ifndef RISCOS
1066 n = p + 1 - argv0; 1074 n = p + 1 - argv0;
1067 #else /* don't include trailing separator */ 1075 #else /* don't include trailing separator */
1068 n = p - argv0; 1076 n = p - argv0;