[issue9009] Improve quality of Python/dtoa.c

Mark Dickinson report at bugs.python.org
Wed Jun 16 21:09:23 CEST 2010


Mark Dickinson <dickinsm at gmail.com> added the comment:

Gay's changes tend to be very small;  any bugfixes he releases can likely be applied by hand, if they're relevant.

I did originally want to keep close to Gay's code, but frankly I'm not very happy with the quality of that code;  and in communications with Gay it's become clear that there are issues that will not be fixed upstream, but that I consider unacceptable for Python's copy of dtoa.c.

Some examples of problems with the original code:

(1) Gay's code does no checking of return values from malloc.  We had to add those checks, which was the first point at which our code started diverging from his.

(2) There's a segment at the beginning of the bigcomp function that's unnecessary, and in fact would produce incorrect results if it were ever called;  it's just about possible to show that it *can't* ever be called.  I've asked David Gay about this, but he insists that it's necessary.  (I've removed it in Python's version of the code.)

(3) The original code silently produces wrong results for huge inputs (more than 20000 characters);  I know this is an extreme use case, but again I find this unacceptable for Python.  (I haven't asked Gay about this;  I'd be very surprised if he wanted to do anything about it, though.)

(4) The original code is horribly convoluted in places, making it very difficult to check for correctness.  (For example, see the spaghetti mess in the parsing section of strtod.c).

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue9009>
_______________________________________


More information about the Python-bugs-list mailing list