diff options
author | Thomas Heller <theller@ctypes.org> | 2003-01-08 14:33:48 (GMT) |
---|---|---|
committer | Thomas Heller <theller@ctypes.org> | 2003-01-08 14:33:48 (GMT) |
commit | 27bb71e96382218a5a530772cd81ce6f91d22444 (patch) | |
tree | 88183265f961ccf4659b4ff389e038ecc3547b93 /Python | |
parent | 326c72a839db912c4010f526b99f48f254c4d532 (diff) | |
download | cpython-27bb71e96382218a5a530772cd81ce6f91d22444.zip cpython-27bb71e96382218a5a530772cd81ce6f91d22444.tar.gz cpython-27bb71e96382218a5a530772cd81ce6f91d22444.tar.bz2 |
Patch #664376: sys.path[0] should contain absolute pathname.
This fixes the problem on Windows - that's the only system where I can
test it.
It leaves sys.argv alone and only changes sys.path[0] to an absolute
pathname.
Diffstat (limited to 'Python')
-rw-r--r-- | Python/sysmodule.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/Python/sysmodule.c b/Python/sysmodule.c index 751d147..2b4c6b4 100644 --- a/Python/sysmodule.c +++ b/Python/sysmodule.c @@ -969,6 +969,9 @@ makeargvobject(int argc, char **argv) void PySys_SetArgv(int argc, char **argv) { +#ifdef MS_WINDOWS + char fullpath[MAX_PATH]; +#endif PyObject *av = makeargvobject(argc, argv); PyObject *path = PySys_GetObject("path"); if (av == NULL) @@ -1011,6 +1014,15 @@ PySys_SetArgv(int argc, char **argv) #if SEP == '\\' /* Special case for MS filename syntax */ if (argc > 0 && argv0 != NULL) { char *q; +#ifdef MS_WINDOWS + char *ptemp; + if (GetFullPathName(argv0, + sizeof(fullpath), + fullpath, + &ptemp)) { + argv0 = fullpath; + } +#endif p = strrchr(argv0, SEP); /* Test for alternate separator */ q = strrchr(p ? p : argv0, '/'); |