Issue5914
Created on 2009-05-03 15:27 by mark.dickinson, last changed 2009-05-03 20:36 by mark.dickinson.
|
msg87048 - (view) |
Author: Mark Dickinson (mark.dickinson) |
Date: 2009-05-03 15:27 |
|
Here's a patch that adds a PyOS_string_to_double function to complement
the recently added PyOS_double_to_string function.
This is supposed to be a more Pythonic version of PyOS_ascii_strtod. It
raises Python exceptions to correspond to the various possible errors
(malformed string, overflowing number, malloc failure...) instead of
requiring the caller to examine errno.
It's intended for both internal and external use; if this goes in, I
intend to use it in the Python core in places where PyOS_ascii_strtod or
PyOS_ascii_atof are currently used.
|
|
msg87049 - (view) |
Author: Eric Smith (eric.smith) |
Date: 2009-05-03 15:36 |
|
This looks okay to me (although since it's not hooked up I haven't
tested it). I particularly like that it doesn't allow leading
whitespace, and that the caller no longer has to remember errno
(forgetting to set and/or test it have both caused me problems in the past).
Does the whitespace change cause any problems for any internal code? I
wouldn't think so, but I haven't looked at it.
As long as you're at it, I'd suggest deprecating PyOS_ascii_*.
|
|
msg87055 - (view) |
Author: Mark Dickinson (mark.dickinson) |
Date: 2009-05-03 17:45 |
|
Thanks for the feedback!
Here's an updated patch that also deprecates PyOS_ascii_strtod and
PyOS_ascii_atof and hooks up PyOS_string_to_double everywhere. The
documentation still needs proper markup, and I'll add some C-API tests.
|
|
msg87057 - (view) |
Author: Eric Smith (eric.smith) |
Date: 2009-05-03 18:32 |
|
This looks okay to me, and passes the tests.
In PyOS_string_to_double, you can simplify it by using PyErr_Format
instead of printing into a buffer and using PyErr_SetString. Sorry I
didn't catch this earlier.
|
|
msg87068 - (view) |
Author: Mark Dickinson (mark.dickinson) |
Date: 2009-05-03 20:36 |
|
Thanks. I've committed a version of this patch, with Eric's suggested
PyErr_Format change, in r72248.
|
|
| Date |
User |
Action |
Args |
| 2009-05-03 20:36:24 | mark.dickinson | set | status: open -> closed resolution: accepted messages:
+ msg87068
stage: patch review -> committed/rejected |
| 2009-05-03 18:32:27 | eric.smith | set | messages:
+ msg87057 |
| 2009-05-03 17:45:26 | mark.dickinson | set | files:
+ string_to_double_v2.patch
messages:
+ msg87055 |
| 2009-05-03 15:36:23 | eric.smith | set | messages:
+ msg87049 stage: patch review |
| 2009-05-03 15:27:14 | mark.dickinson | create | |
|