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

Argument Clinic incorrectly works with custom converter and renamed parameter #71089

Closed
serhiy-storchaka opened this issue May 1, 2016 · 3 comments
Labels
topic-argument-clinic type-bug An unexpected behavior, bug, or error

Comments

@serhiy-storchaka
Copy link
Member

BPO 26902
Nosy @larryhastings, @serhiy-storchaka
Files
  • issue26902_sample.c
  • 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 2016-05-02.06:39:29.262>
    created_at = <Date 2016-05-01.18:45:28.648>
    labels = ['type-bug', 'invalid', 'expert-argument-clinic']
    title = 'Argument Clinic incorrectly works with custom converter and renamed parameter'
    updated_at = <Date 2016-05-02.08:33:16.673>
    user = 'https://github.com/serhiy-storchaka'

    bugs.python.org fields:

    activity = <Date 2016-05-02.08:33:16.673>
    actor = 'serhiy.storchaka'
    assignee = 'none'
    closed = True
    closed_date = <Date 2016-05-02.06:39:29.262>
    closer = 'larry'
    components = ['Argument Clinic']
    creation = <Date 2016-05-01.18:45:28.648>
    creator = 'serhiy.storchaka'
    dependencies = []
    files = ['42674']
    hgrepos = []
    issue_num = 26902
    keywords = []
    message_count = 3.0
    messages = ['264606', '264627', '264630']
    nosy_count = 2.0
    nosy_names = ['larry', 'serhiy.storchaka']
    pr_nums = []
    priority = 'normal'
    resolution = 'not a bug'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue26902'
    versions = ['Python 3.5', 'Python 3.6']

    @serhiy-storchaka
    Copy link
    Member Author

    Argument Clinic uses original name of Python parameter in generated code for custom (format code "O&") converter even if the parameter was renamed.

    Example:

    /[clinic input]
    test
    filename as path: object(converter="PyUnicode_FSConverter")
    /
    [clinic start generated code]
    /

    Generated code:

    static PyObject *
    test(PyModuleDef *module, PyObject *arg)
    {
        PyObject *return_value = NULL;
        PyObject *path;
    if (!PyUnicode_FSConverter(arg, &filename))
        goto exit;
    return_value = test_impl(module, path);
    
    exit:
        return return_value;
    }

    @serhiy-storchaka serhiy-storchaka added topic-argument-clinic type-bug An unexpected behavior, bug, or error labels May 1, 2016
    @serhiy-storchaka serhiy-storchaka changed the title Argument Clinic incorrectly work with custom converter and renamed parameter Argument Clinic incorrectly works with custom converter and renamed parameter May 1, 2016
    @larryhastings
    Copy link
    Contributor

    This is caused by your "meth_o inline" code, which isn't checked in yet. A clean checkout of CPython trunk generates this correct code:

        if (!PyArg_Parse(arg, "O&:test", PyUnicode_FSConverter, &path))

    Maybe you don't need to use bugs.python.org as your personal bug tracker; maybe you don't need to add me to your private bugs.

    @serhiy-storchaka
    Copy link
    Member Author

    You are right. Sorry for the noise.

    @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
    topic-argument-clinic type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants