summaryrefslogtreecommitdiffstats
path: root/Modules/stropmodule.c
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1996-08-21 20:02:25 (GMT)
committerGuido van Rossum <guido@python.org>1996-08-21 20:02:25 (GMT)
commit171191efb292cb731d7c8fd8bd7d0b1f550948f5 (patch)
tree6b39480d19ffa3424e64c489e947d6d502c2a8ef /Modules/stropmodule.c
parentd0f11dec30378688ced23e21623f541c3ff008c3 (diff)
downloadcpython-171191efb292cb731d7c8fd8bd7d0b1f550948f5.zip
cpython-171191efb292cb731d7c8fd8bd7d0b1f550948f5.tar.gz
cpython-171191efb292cb731d7c8fd8bd7d0b1f550948f5.tar.bz2
Raise ValueError on empty string passed into atoi(), atol(), atof().
Diffstat (limited to 'Modules/stropmodule.c')
-rw-r--r--Modules/stropmodule.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/Modules/stropmodule.c b/Modules/stropmodule.c
index ef943a4..0540a9d 100644
--- a/Modules/stropmodule.c
+++ b/Modules/stropmodule.c
@@ -537,6 +537,10 @@ strop_atoi(self, args)
}
else if (!getargs(args, "s", &s))
return NULL;
+ if (s[0] == '\0') {
+ err_setstr(ValueError, "empty string for atoi()");
+ return NULL;
+ }
errno = 0;
if (base == 0 && s[0] == '0')
x = (long) mystrtoul(s, &end, base);
@@ -573,6 +577,10 @@ strop_atol(self, args)
}
else if (!getargs(args, "s", &s))
return NULL;
+ if (s[0] == '\0') {
+ err_setstr(ValueError, "empty string for atol()");
+ return NULL;
+ }
x = long_escan(s, &end, base);
if (x == NULL)
return NULL;
@@ -598,6 +606,10 @@ strop_atof(self, args)
if (!getargs(args, "s", &s))
return NULL;
+ if (s[0] == '\0') {
+ err_setstr(ValueError, "empty string for atof()");
+ return NULL;
+ }
errno = 0;
x = strtod(s, &end);
if (*end != '\0') {