diff options
author | Guido van Rossum <guido@python.org> | 2003-02-19 15:25:10 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 2003-02-19 15:25:10 (GMT) |
commit | 162e38c6a312aa3e9c353419301087a4620c513c (patch) | |
tree | 7cbea919a90b99c00446bfa35905821b8dc7ee44 /Python | |
parent | 80be59b275dfd62545c69ca377bae02c02648839 (diff) | |
download | cpython-162e38c6a312aa3e9c353419301087a4620c513c.zip cpython-162e38c6a312aa3e9c353419301087a4620c513c.tar.gz cpython-162e38c6a312aa3e9c353419301087a4620c513c.tar.bz2 |
- 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.)
Diffstat (limited to 'Python')
-rw-r--r-- | Python/sysmodule.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/Python/sysmodule.c b/Python/sysmodule.c index 765621e..1f51f98 100644 --- a/Python/sysmodule.c +++ b/Python/sysmodule.c @@ -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; |