Mercurial > cpython-lru_cache-weakref
diff Python/sysmodule.c @ 3877:408e374934e5 legacy-trunk
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).
| author | Guido van Rossum <guido@python.org> |
|---|---|
| date | Tue, 30 Jul 1996 20:35:50 +0000 |
| parents | 93868c7a15c9 |
| children | c80c515999b9 |
line wrap: on
line diff
--- a/Python/sysmodule.c Tue Jul 30 20:16:21 1996 +0000 +++ b/Python/sysmodule.c Tue Jul 30 20:35:50 1996 +0000 @@ -360,27 +360,27 @@ 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); }
