bpo-27268: Fix incorrect error message on float('') (GH-2745)
authorPedro Lacerda <pslacerda@users.noreply.github.com>
Fri, 17 May 2019 22:32:44 +0000 (19:32 -0300)
committerCheryl Sabella <cheryl.sabella@gmail.com>
Fri, 17 May 2019 22:32:44 +0000 (18:32 -0400)
Python/pystrtod.c

index 02a3fb57805cf54d7cd215d7a5cc4336c2d55c2c..4aa99d546caf9e7286c5e59bebc2e5e5cf5015b8 100644 (file)
@@ -353,15 +353,15 @@ PyOS_string_to_double(const char *s,
     else if (!endptr && (fail_pos == s || *fail_pos != '\0'))
         PyErr_Format(PyExc_ValueError,
                       "could not convert string to float: "
-                      "%.200s", s);
+                      "'%.200s'", s);
     else if (fail_pos == s)
         PyErr_Format(PyExc_ValueError,
                       "could not convert string to float: "
-                      "%.200s", s);
+                      "'%.200s'", s);
     else if (errno == ERANGE && fabs(x) >= 1.0 && overflow_exception)
         PyErr_Format(overflow_exception,
                       "value too large to convert to float: "
-                      "%.200s", s);
+                      "'%.200s'", s);
     else
         result = x;