- 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.)
This commit is contained in:
Guido van Rossum 2003-02-19 15:25:10 +00:00
parent 80be59b275
commit 162e38c6a3
5 changed files with 21 additions and 5 deletions

View 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;