mirror of
https://github.com/python/cpython.git
synced 2025-10-30 13:11:29 +00:00
Always insert script directory in front of sys.path -- if there's no
sys.argv, insert "". Note that "." is removed as a default component of the path (see changes to getpath.c and Setup.in).
This commit is contained in:
parent
9afdabffa9
commit
94a9667f1a
1 changed files with 17 additions and 17 deletions
|
|
@ -360,16 +360,17 @@ setpythonargv(argc, argv)
|
||||||
char **argv;
|
char **argv;
|
||||||
{
|
{
|
||||||
object *av = makeargvobject(argc, argv);
|
object *av = makeargvobject(argc, argv);
|
||||||
|
object *path = sysget("path");
|
||||||
if (av == NULL)
|
if (av == NULL)
|
||||||
fatal("no mem for sys.argv");
|
fatal("no mem for sys.argv");
|
||||||
if (sysset("argv", av) != 0)
|
if (sysset("argv", av) != 0)
|
||||||
fatal("can't assign sys.argv");
|
fatal("can't assign sys.argv");
|
||||||
if (argc > 0) {
|
|
||||||
object *path = sysget("path");
|
|
||||||
if (path != NULL) {
|
if (path != NULL) {
|
||||||
char *p = strrchr(argv[0], SEP);
|
char *p = NULL;
|
||||||
int n;
|
int n;
|
||||||
object *a;
|
object *a;
|
||||||
|
if (argc > 0 && argv[0] != NULL)
|
||||||
|
p = strrchr(argv[0], SEP);
|
||||||
if (p == NULL)
|
if (p == NULL)
|
||||||
n = 0;
|
n = 0;
|
||||||
else
|
else
|
||||||
|
|
@ -381,6 +382,5 @@ setpythonargv(argc, argv)
|
||||||
fatal("sys.path.insert(0) failed");
|
fatal("sys.path.insert(0) failed");
|
||||||
DECREF(a);
|
DECREF(a);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
DECREF(av);
|
DECREF(av);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue