Movatterモバイル変換


[0]ホーム

URL:


homepage

Issue5914

This issue trackerhas been migrated toGitHub, and is currentlyread-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title:Add PyOS_string_to_double function to C API
Type:enhancementStage:resolved
Components:Interpreter CoreVersions:Python 3.1
process
Status:closedResolution:accepted
Dependencies:Superseder:
Assigned To: mark.dickinsonNosy List: eric.smith, mark.dickinson
Priority:normalKeywords:patch

Created on2009-05-03 15:27 bymark.dickinson, last changed2022-04-11 14:56 byadmin. This issue is nowclosed.

Files
File nameUploadedDescriptionEdit
string_to_double.patchmark.dickinson,2009-05-03 15:27
string_to_double_v2.patchmark.dickinson,2009-05-03 17:45
Messages (5)
msg87048 -(view)Author: Mark Dickinson (mark.dickinson)*(Python committer)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)*(Python committer)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)*(Python committer)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)*(Python committer)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)*(Python committer)Date: 2009-05-03 20:36
Thanks.  I've committed a version of this patch, with Eric's suggested PyErr_Format change, inr72248.
History
DateUserActionArgs
2022-04-11 14:56:48adminsetgithub: 50164
2009-05-03 20:36:24mark.dickinsonsetstatus: open -> closed
resolution: accepted
messages: +msg87068

stage: patch review -> resolved
2009-05-03 18:32:27eric.smithsetmessages: +msg87057
2009-05-03 17:45:26mark.dickinsonsetfiles: +string_to_double_v2.patch

messages: +msg87055
2009-05-03 15:36:23eric.smithsetmessages: +msg87049
stage: patch review
2009-05-03 15:27:14mark.dickinsoncreate
Supported byThe Python Software Foundation,
Powered byRoundup
Copyright © 1990-2022,Python Software Foundation
Legal Statements

[8]ページ先頭

©2009-2026 Movatter.jp