comparison Python/sysmodule.c @ 27156:585a6460f577 legacy-trunk

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.
author Thomas Heller <theller@ctypes.org>
date Wed, 08 Jan 2003 14:33:48 +0000
parents 4a825b902310
children 16856c9514e0
comparison
equal deleted inserted replaced
27155:3f4e80ebdca8 27156:585a6460f577
967 } 967 }
968 968
969 void 969 void
970 PySys_SetArgv(int argc, char **argv) 970 PySys_SetArgv(int argc, char **argv)
971 { 971 {
972 #ifdef MS_WINDOWS
973 char fullpath[MAX_PATH];
974 #endif
972 PyObject *av = makeargvobject(argc, argv); 975 PyObject *av = makeargvobject(argc, argv);
973 PyObject *path = PySys_GetObject("path"); 976 PyObject *path = PySys_GetObject("path");
974 if (av == NULL) 977 if (av == NULL)
975 Py_FatalError("no mem for sys.argv"); 978 Py_FatalError("no mem for sys.argv");
976 if (PySys_SetObject("argv", av) != 0) 979 if (PySys_SetObject("argv", av) != 0)
1009 } 1012 }
1010 #endif /* HAVE_READLINK */ 1013 #endif /* HAVE_READLINK */
1011 #if SEP == '\\' /* Special case for MS filename syntax */ 1014 #if SEP == '\\' /* Special case for MS filename syntax */
1012 if (argc > 0 && argv0 != NULL) { 1015 if (argc > 0 && argv0 != NULL) {
1013 char *q; 1016 char *q;
1017 #ifdef MS_WINDOWS
1018 char *ptemp;
1019 if (GetFullPathName(argv0,
1020 sizeof(fullpath),
1021 fullpath,
1022 &ptemp)) {
1023 argv0 = fullpath;
1024 }
1025 #endif
1014 p = strrchr(argv0, SEP); 1026 p = strrchr(argv0, SEP);
1015 /* Test for alternate separator */ 1027 /* Test for alternate separator */
1016 q = strrchr(p ? p : argv0, '/'); 1028 q = strrchr(p ? p : argv0, '/');
1017 if (q != NULL) 1029 if (q != NULL)
1018 p = q; 1030 p = q;