Issue #1672332: Fix unpickling of subnormal floats, which was raising
ValueError on some platforms as a result of the platform strtod setting
errno on underflow.
diff --git a/Modules/cPickle.c b/Modules/cPickle.c
index 7f836c3..fb13ba1 100644
--- a/Modules/cPickle.c
+++ b/Modules/cPickle.c
@@ -3465,7 +3465,8 @@
errno = 0;
d = PyOS_ascii_strtod(s, &endptr);
- if (errno || (endptr[0] != '\n') || (endptr[1] != '\0')) {
+ if ((errno == ERANGE && !(fabs(d) <= 1.0)) ||
+ (endptr[0] != '\n') || (endptr[1] != '\0')) {
PyErr_SetString(PyExc_ValueError,
"could not convert string to float");
goto finally;