mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
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.
This commit is contained in:
parent
326c72a839
commit
27bb71e963
1 changed files with 12 additions and 0 deletions
|
@ -969,6 +969,9 @@ makeargvobject(int argc, char **argv)
|
||||||
void
|
void
|
||||||
PySys_SetArgv(int argc, char **argv)
|
PySys_SetArgv(int argc, char **argv)
|
||||||
{
|
{
|
||||||
|
#ifdef MS_WINDOWS
|
||||||
|
char fullpath[MAX_PATH];
|
||||||
|
#endif
|
||||||
PyObject *av = makeargvobject(argc, argv);
|
PyObject *av = makeargvobject(argc, argv);
|
||||||
PyObject *path = PySys_GetObject("path");
|
PyObject *path = PySys_GetObject("path");
|
||||||
if (av == NULL)
|
if (av == NULL)
|
||||||
|
@ -1011,6 +1014,15 @@ PySys_SetArgv(int argc, char **argv)
|
||||||
#if SEP == '\\' /* Special case for MS filename syntax */
|
#if SEP == '\\' /* Special case for MS filename syntax */
|
||||||
if (argc > 0 && argv0 != NULL) {
|
if (argc > 0 && argv0 != NULL) {
|
||||||
char *q;
|
char *q;
|
||||||
|
#ifdef MS_WINDOWS
|
||||||
|
char *ptemp;
|
||||||
|
if (GetFullPathName(argv0,
|
||||||
|
sizeof(fullpath),
|
||||||
|
fullpath,
|
||||||
|
&ptemp)) {
|
||||||
|
argv0 = fullpath;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
p = strrchr(argv0, SEP);
|
p = strrchr(argv0, SEP);
|
||||||
/* Test for alternate separator */
|
/* Test for alternate separator */
|
||||||
q = strrchr(p ? p : argv0, '/');
|
q = strrchr(p ? p : argv0, '/');
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue