Serhiy Storchaka added the comment:

I tried to make a workaround with using default value instead of optional 
group, but for the following declaration an incorrect code is generated:

/*[clinic input]
_curses.window.getstr

    [
    y: int
        Y-coordinate.
    x: int
        X-coordinate.
    ]
    n: int = 1023
    /

[clinic start generated code]*/

Generated code is:

static PyObject *
_curses_window_getstr(PyCursesWindowObject *self, PyObject *args)
{
    PyObject *return_value = NULL;
    int group_left_1 = 0;
    int y = 0;
    int x = 0;
    int n = 1023;

    switch (PyTuple_GET_SIZE(args)) {
        case 1:
            if (!PyArg_ParseTuple(args, "i:getstr", &n))
                goto exit;
            break;
        case 3:
            if (!PyArg_ParseTuple(args, "iii:getstr", &y, &x, &n))
                goto exit;
            group_left_1 = 1;
            break;
        default:
            PyErr_SetString(PyExc_TypeError, "_curses.window.getstr requires 1 
to 3 arguments");
            goto exit;
    }
    return_value = _curses_window_getstr_impl(self, group_left_1, y, x, n);

exit:
    return return_value;
}

Expected generated code:

static PyObject *
_curses_window_getstr(PyCursesWindowObject *self, PyObject *args)
{
    PyObject *return_value = NULL;
    int group_left_1 = 0;
    int y = 0;
    int x = 0;
    int n = 1023;

    switch (PyTuple_GET_SIZE(args)) {
        case 0:
        case 1:
            if (!PyArg_ParseTuple(args, "|i:getstr", &n))
                goto exit;
            break;
        case 2:
        case 3:
            if (!PyArg_ParseTuple(args, "ii|i:getstr", &y, &x, &n))
                goto exit;
            group_left_1 = 1;
            break;
        default:
            PyErr_SetString(PyExc_TypeError, "_curses.window.getstr requires 0 
to 3 arguments");
            goto exit;
    }
    return_value = _curses_window_getstr_impl(self, group_left_1, y, x, n);

exit:
    return return_value;
}

This bug looks similar to issue24051.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue20303>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to