]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Ensure that sys.argv[0] always exists (maybe as empty string).
authorGuido van Rossum <guido@python.org>
Tue, 14 Jan 1992 18:42:53 +0000 (18:42 +0000)
committerGuido van Rossum <guido@python.org>
Tue, 14 Jan 1992 18:42:53 +0000 (18:42 +0000)
Python/sysmodule.c

index c8460682cb0169295716bff22f705da7565d415f..d725c88cc8b0debf8e0404cc022bc11e3ba3c5e4 100644 (file)
@@ -187,8 +187,12 @@ makeargvobject(argc, argv)
        char **argv;
 {
        object *av;
-       if (argc < 0 || argv == NULL)
-               argc = 0;
+       if (argc <= 0 || argv == NULL) {
+               /* Ensure at least one (empty) argument is seen */
+               static char *empty_argv[1] = {""};
+               argv = empty_argv;
+               argc = 1;
+       }
        av = newlistobject(argc);
        if (av != NULL) {
                int i;