On 06/06/2017 12:51 PM, Chris Angelico wrote: > Firstly, is there a reason for the empty string to not be surrounded > with quotes? The source code, AIUI, is this: > > x = PyOS_string_to_double(s, (char **)&end, NULL); > if (end != last) { > PyErr_Format(PyExc_ValueError, > "could not convert string to float: " > "%R", obj); > return NULL; > } > > which, by my reading, should always be repr'ing the string. >
The confusing part is that if the string is empty, then the line if (end != last) { does not evaluate to true. So you never enter that part of the if statement. Instead you get here: else if (x == -1.0 && PyErr_Occurred()) { return NULL; } (You can check in a debugger that this happens.) Cheers, Thomas _______________________________________________ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/