diff options
author | Guido van Rossum <guido@python.org> | 1992-01-14 18:42:53 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 1992-01-14 18:42:53 (GMT) |
commit | ee3a299c396593a277060e0b991b62179eed1086 (patch) | |
tree | 4450807e2964799e1f2e2caf1989199c45848433 /Python/sysmodule.c | |
parent | 23d5cdebacba5488dbb97fbe2f776d3fcd35432f (diff) | |
download | cpython-ee3a299c396593a277060e0b991b62179eed1086.zip cpython-ee3a299c396593a277060e0b991b62179eed1086.tar.gz cpython-ee3a299c396593a277060e0b991b62179eed1086.tar.bz2 |
Ensure that sys.argv[0] always exists (maybe as empty string).
Diffstat (limited to 'Python/sysmodule.c')
-rw-r--r-- | Python/sysmodule.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/Python/sysmodule.c b/Python/sysmodule.c index c846068..d725c88 100644 --- a/Python/sysmodule.c +++ b/Python/sysmodule.c @@ -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; |