Commit 765007e4 authored by Guido van Rossum's avatar Guido van Rossum

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).
parent dc979d29
......@@ -360,27 +360,27 @@ setpythonargv(argc, argv)
char **argv;
{
object *av = makeargvobject(argc, argv);
object *path = sysget("path");
if (av == NULL)
fatal("no mem for sys.argv");
if (sysset("argv", av) != 0)
fatal("can't assign sys.argv");
if (argc > 0) {
object *path = sysget("path");
if (path != NULL) {
char *p = strrchr(argv[0], SEP);
int n;
object *a;
if (p == NULL)
n = 0;
else
n = p + 1 - argv[0];
a = newsizedstringobject(argv[0], n);
if (a == NULL)
fatal("no mem for sys.path insertion");
if (inslistitem(path, 0, a) < 0)
fatal("sys.path.insert(0) failed");
DECREF(a);
}
if (path != NULL) {
char *p = NULL;
int n;
object *a;
if (argc > 0 && argv[0] != NULL)
p = strrchr(argv[0], SEP);
if (p == NULL)
n = 0;
else
n = p + 1 - argv[0];
a = newsizedstringobject(argv[0], n);
if (a == NULL)
fatal("no mem for sys.path insertion");
if (inslistitem(path, 0, a) < 0)
fatal("sys.path.insert(0) failed");
DECREF(a);
}
DECREF(av);
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment