summaryrefslogtreecommitdiffstats
path: root/Modules/_pickle.c
diff options
context:
space:
mode:
authorMark Dickinson <dickinsm@gmail.com>2009-05-03 20:33:40 (GMT)
committerMark Dickinson <dickinsm@gmail.com>2009-05-03 20:33:40 (GMT)
commit725bfd8489e444aedd8dfd686a27ffc308657155 (patch)
tree99d4e0cc2953794a67a5cff491e1897723a119ff /Modules/_pickle.c
parent75930f85df76472686a8c4eb587a2a70562f61fe (diff)
downloadcpython-725bfd8489e444aedd8dfd686a27ffc308657155.zip
cpython-725bfd8489e444aedd8dfd686a27ffc308657155.tar.gz
cpython-725bfd8489e444aedd8dfd686a27ffc308657155.tar.bz2
Issue #5914: Add new C-API function PyOS_string_to_double, to complement
PyOS_double_to_string, and deprecate PyOS_ascii_strtod and PyOS_ascii_atof.
Diffstat (limited to 'Modules/_pickle.c')
-rw-r--r--Modules/_pickle.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/Modules/_pickle.c b/Modules/_pickle.c
index 754d132..8adc136 100644
--- a/Modules/_pickle.c
+++ b/Modules/_pickle.c
@@ -2971,20 +2971,20 @@ load_float(UnpicklerObject *self)
return bad_readline();
errno = 0;
- d = PyOS_ascii_strtod(s, &endptr);
-
- if ((errno == ERANGE && !(fabs(d) <= 1.0)) ||
- (endptr[0] != '\n') || (endptr[1] != '\0')) {
+ d = PyOS_string_to_double(s, &endptr, PyExc_OverflowError);
+ if (d == -1.0 && PyErr_Occurred())
+ return -1;
+ if ((endptr[0] != '\n') || (endptr[1] != '\0')) {
PyErr_SetString(PyExc_ValueError, "could not convert string to float");
return -1;
}
-
- if ((value = PyFloat_FromDouble(d)) == NULL)
+ value = PyFloat_FromDouble(d);
+ if (value == NULL)
return -1;
PDATA_PUSH(self->stack, value, -1);
return 0;
-}
+ }
static int
load_binfloat(UnpicklerObject *self)