Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate correct error check for PyFloat_AsDouble #82123

Closed
rhettinger opened this issue Aug 24, 2019 · 5 comments
Closed

Generate correct error check for PyFloat_AsDouble #82123

rhettinger opened this issue Aug 24, 2019 · 5 comments
Labels
3.8 (EOL) end of life 3.9 only security fixes topic-argument-clinic type-bug An unexpected behavior, bug, or error

Comments

@rhettinger
Copy link
Contributor

BPO 37942
Nosy @rhettinger, @larryhastings, @serhiy-storchaka
PRs
  • bpo-37942: Improve argument clinic float converter #15470
  • [3.8] bpo-37942: Improve argument clinic float converter (GH-15470) #15480
  • 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

    GitHub fields:

    assignee = None
    closed_at = <Date 2019-08-25.02:45:37.328>
    created_at = <Date 2019-08-24.19:09:51.270>
    labels = ['type-bug', '3.8', 'expert-argument-clinic', '3.9']
    title = 'Generate correct error check for PyFloat_AsDouble'
    updated_at = <Date 2019-08-25.09:41:06.925>
    user = 'https://github.com/rhettinger'

    bugs.python.org fields:

    activity = <Date 2019-08-25.09:41:06.925>
    actor = 'serhiy.storchaka'
    assignee = 'none'
    closed = True
    closed_date = <Date 2019-08-25.02:45:37.328>
    closer = 'rhettinger'
    components = ['Argument Clinic']
    creation = <Date 2019-08-24.19:09:51.270>
    creator = 'rhettinger'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 37942
    keywords = ['patch']
    message_count = 5.0
    messages = ['350395', '350397', '350419', '350422', '350443']
    nosy_count = 3.0
    nosy_names = ['rhettinger', 'larry', 'serhiy.storchaka']
    pr_nums = ['15470', '15480']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue37942'
    versions = ['Python 3.8', 'Python 3.9']

    @rhettinger
    Copy link
    Contributor Author

    The API for PyFloat_AsDouble() returns -1.0 to indicate an error. PyErr_Occurred() should only be called if there is a -1.0 return code. This is the normal practice for those calls and it is a bit faster because it avoids unnecessary external call.

    @rhettinger rhettinger added 3.8 (EOL) end of life 3.9 only security fixes topic-argument-clinic type-bug An unexpected behavior, bug, or error labels Aug 24, 2019
    @rhettinger
    Copy link
    Contributor Author

    Note, the argument clinic is already generating code like this for return values in "class double_return_converter". For example,

        _return_value = _statistics__normal_dist_inv_cdf_impl(module, p, mu, sigma);
        if ((_return_value == -1.0) && PyErr_Occurred()) {
    	goto exit;
        }

    @rhettinger
    Copy link
    Contributor Author

    New changeset aef9ad8 by Raymond Hettinger in branch 'master':
    bpo-37942: Improve argument clinic float converter (GH-15470)
    aef9ad8

    @rhettinger
    Copy link
    Contributor Author

    New changeset 21161d7 by Raymond Hettinger in branch '3.8':
    [3.8] bpo-37942: Improve argument clinic float converter (GH-15470) (GH-15480)
    21161d7

    @serhiy-storchaka
    Copy link
    Member

    How large is benefit from special casing exact floats?

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.8 (EOL) end of life 3.9 only security fixes topic-argument-clinic type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants