]> granicus.if.org Git - python/commitdiff
Patch #664376: sys.path[0] should contain absolute pathname.
authorThomas Heller <theller@ctypes.org>
Wed, 8 Jan 2003 14:33:48 +0000 (14:33 +0000)
committerThomas Heller <theller@ctypes.org>
Wed, 8 Jan 2003 14:33:48 +0000 (14:33 +0000)
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.

Python/sysmodule.c

index 751d14758336cc809bb9cb3a5904a079ce76d978..2b4c6b49a0756df5444b5f8578f4c3d11458a280 100644 (file)
@@ -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, '/');