python / cpython

The Python programming language
https://www.python.org
Other
62.33k stars 29.94k forks source link

Argument Clinic generates wrong keyword parameter name for "default" #64356

Closed serhiy-storchaka closed 10 years ago

serhiy-storchaka commented 10 years ago
BPO 20157
Nosy @larryhastings, @serhiy-storchaka
Files
  • spammodule.c
  • larry.clinic.keyword.renamer.diff.1.txt
  • 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: ```python assignee = 'https://github.com/larryhastings' closed_at = created_at = labels = ['type-bug', 'build'] title = 'Argument Clinic generates wrong keyword parameter name for "default"' updated_at = user = 'https://github.com/serhiy-storchaka' ``` bugs.python.org fields: ```python activity = actor = 'larry' assignee = 'larry' closed = True closed_date = closer = 'larry' components = ['Build'] creation = creator = 'serhiy.storchaka' dependencies = [] files = ['33337', '33346'] hgrepos = [] issue_num = 20157 keywords = [] message_count = 4.0 messages = ['207513', '207517', '207561', '207589'] nosy_count = 3.0 nosy_names = ['larry', 'python-dev', 'serhiy.storchaka'] pr_nums = [] priority = 'normal' resolution = 'fixed' stage = 'resolved' status = 'closed' superseder = None type = 'behavior' url = 'https://bugs.python.org/issue20157' versions = ['Python 3.4'] ```

    serhiy-storchaka commented 10 years ago

    For the "default" keyword parameter Argument Clinic generates wrong name "default_value" in the _keywords array.

    /*[clinic] module spam spam.ham

    default: int = 1

    [clinic]*/

    ...

    static PyObject *
    spam_ham(PyModuleDef *module, PyObject *args, PyObject *kwargs)
    {
        PyObject *return_value = NULL;
        static char *_keywords[] = {"default_value", NULL};
        int default_value = 1;
        if (!PyArg_ParseTupleAndKeywords(args, kwargs,
            "|i:ham", _keywords,
            &default_value))
            goto exit;
    ...
    larryhastings commented 10 years ago

    I'll fix this but it's low priority for today.

    It's not a release blocker; we could release Python 3.4 with this bug.

    larryhastings commented 10 years ago

    The problem was an easy fix. However, while fixing it I discovered another problem (if "[clinic]/" was the last line, and it didn't have an eol, Clinic would append another "[clinic]/"). I fixed that too and added a regression test.

    Okay?

    1762cc99-3127-4a62-9baf-30c3d0f51ef7 commented 10 years ago

    New changeset f61c63ec4e70 by Larry Hastings in branch 'default': Issue bpo-20157: When Argument Clinic renames a parameter because its name http://hg.python.org/cpython/rev/f61c63ec4e70