From 162e38c6a312aa3e9c353419301087a4620c513c Mon Sep 17 00:00:00 2001 From: Guido van Rossum Date: Wed, 19 Feb 2003 15:25:10 +0000 Subject: - 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.) --- Python/sysmodule.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'Python/sysmodule.c') diff --git a/Python/sysmodule.c b/Python/sysmodule.c index 765621ecdb..1f51f988f9 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; -- cgit v1.2.1