summaryrefslogtreecommitdiff
path: root/Python
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1996-07-30 20:35:50 +0000
committerGuido van Rossum <guido@python.org>1996-07-30 20:35:50 +0000
commit765007e45adbcc88c1b8f66471230700e23c03ea (patch)
tree84fc0eb433c5f5f80235df0aa75d24c796338b1f /Python
parentdc979d294d3d3af055549375afb73e416b1c8fd7 (diff)
downloadcpython-765007e45adbcc88c1b8f66471230700e23c03ea.tar.gz
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).
Diffstat (limited to 'Python')
-rw-r--r--Python/sysmodule.c34
1 files changed, 17 insertions, 17 deletions
diff --git a/Python/sysmodule.c b/Python/sysmodule.c
index 1b6fab87b9..1dc8e177ac 100644
--- a/Python/sysmodule.c
+++ b/Python/sysmodule.c
@@ -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);
}