diff Python/sysmodule.c @ 596:e18f1fa398a3 legacy-trunk

Ensure that sys.argv[0] always exists (maybe as empty string).
author Guido van Rossum <guido@python.org>
date Tue, 14 Jan 1992 18:42:53 +0000
parents 4efff6cea90f
children f5a2bc39e10e
line wrap: on
line diff
--- a/Python/sysmodule.c	Tue Jan 14 18:42:23 1992 +0000
+++ b/Python/sysmodule.c	Tue Jan 14 18:42:53 1992 +0000
@@ -187,8 +187,12 @@
 	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;