
This issue trackerhas been migrated toGitHub, and is currentlyread-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.
Created on2009-05-03 15:27 bymark.dickinson, last changed2022-04-11 14:56 byadmin. This issue is nowclosed.
| Files | ||||
|---|---|---|---|---|
| File name | Uploaded | Description | Edit | |
| string_to_double.patch | mark.dickinson,2009-05-03 15:27 | |||
| string_to_double_v2.patch | mark.dickinson,2009-05-03 17:45 | |||
| Messages (5) | |||
|---|---|---|---|
| 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 V. Smith (eric.smith)*![]() | Date: 2009-05-03 15:36 | |
This looks okay to me (although since it's not hooked up I haven'ttested it). I particularly like that it doesn't allow leadingwhitespace, 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? Iwouldn'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 V. 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_Formatinstead of printing into a buffer and using PyErr_SetString. Sorry Ididn'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, inr72248. | |||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022-04-11 14:56:48 | admin | set | github: 50164 |
| 2009-05-03 20:36:24 | mark.dickinson | set | status: open -> closed resolution: accepted messages: +msg87068 stage: patch review -> resolved |
| 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 | |