You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
assignee='https://github.com/mdickinson'closed_at=<Date2009-05-03.20:36:24.613>created_at=<Date2009-05-03.15:27:14.613>labels= ['interpreter-core', 'type-feature']
title='Add PyOS_string_to_double function to C API'updated_at=<Date2009-05-03.20:36:24.611>user='https://github.com/mdickinson'
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.
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_*.
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.