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 no longer works with single optional argument #68239

Closed
serhiy-storchaka opened this issue Apr 24, 2015 · 6 comments
Closed

Argument Clinic no longer works with single optional argument #68239

serhiy-storchaka opened this issue Apr 24, 2015 · 6 comments
Labels
topic-argument-clinic type-bug An unexpected behavior, bug, or error

Comments

@serhiy-storchaka
Copy link
Member

BPO 24051
Nosy @larryhastings, @serhiy-storchaka

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 2015-05-03.20:14:52.510>
created_at = <Date 2015-04-24.13:48:50.646>
labels = ['type-bug', 'expert-argument-clinic']
title = 'Argument Clinic no longer works with single optional argument'
updated_at = <Date 2015-05-03.20:14:52.509>
user = 'https://github.com/serhiy-storchaka'

bugs.python.org fields:

activity = <Date 2015-05-03.20:14:52.509>
actor = 'larry'
assignee = 'none'
closed = True
closed_date = <Date 2015-05-03.20:14:52.510>
closer = 'larry'
components = ['Argument Clinic']
creation = <Date 2015-04-24.13:48:50.646>
creator = 'serhiy.storchaka'
dependencies = []
files = []
hgrepos = []
issue_num = 24051
keywords = []
message_count = 6.0
messages = ['241943', '242500', '242501', '242515', '242516', '242517']
nosy_count = 2.0
nosy_names = ['larry', 'serhiy.storchaka']
pr_nums = []
priority = 'normal'
resolution = 'wont fix'
stage = 'needs patch'
status = 'closed'
superseder = None
type = 'behavior'
url = 'https://bugs.python.org/issue24051'
versions = ['Python 3.5']

@serhiy-storchaka
Copy link
Member Author

Argument Clinic no longer works single optional argument. For example see _tkinter.tkapp.wantobjects in the patch in bpo-20168.

/*[clinic input]
_tkinter.tkapp.wantobjects

[
value: int
]
/

[clinic start generated code]*/

It is converted to the methoddef of type METH_O.

#define _TKINTER_TKAPP_WANTOBJECTS_METHODDEF    \
    {"wantobjects", (PyCFunction)_tkinter_tkapp_wantobjects, METH_O, _tkinter_tkapp_wantobjects__doc__},

static PyObject *
_tkinter_tkapp_wantobjects(PyObject *self, PyObject *arg)
{
    PyObject *return_value = NULL;
    int group_right_1 = 0;
    int value = 0;
    if (!PyArg_Parse(arg, "i:wantobjects", &value))
        goto exit;
    return_value = _tkinter_tkapp_wantobjects_impl(self, group_right_1, value);
exit:
    return return_value;
}

As result wantobjects() can't be called without an argument.

@serhiy-storchaka serhiy-storchaka added topic-argument-clinic type-bug An unexpected behavior, bug, or error labels Apr 24, 2015
@larryhastings
Copy link
Contributor

Optional groups were designed to support two specific legacy use cases:

  • functions that have groups of parameters that are
  • functions with optional parameters to the left of required parameters

They are not intended to be used in cases like this. I really, really wish you would stop using them except for these specific legacy cases.

Furthermore, the argument parsing for tkinter.tkapp.wantobjects has a very clear translation into Argument Clinic:

value: int = -1
/

Optional groups should not be used for single-argument functions. I have no interest in fixing this bug.

@larryhastings
Copy link
Contributor

Sorry, I forgot to finish the first bullet point. It should have read:

  • functions that have groups of parameters that are optional only as a group (e.g. curses.window.getch)

@serhiy-storchaka
Copy link
Member Author

Then it would be better to not convert wantobjects() to Argument Clinic. Using -1 as a value for not passed argument is a hack (added in 1ab9978123be) and I don't want to propagate it to the signature.

But I afraid that there are other functions that suffer from this bug (may be in the curses module).

@serhiy-storchaka serhiy-storchaka added the stale Stale PR or inactive for long period of time. label May 3, 2015
@larryhastings
Copy link
Contributor

If the argument currently uses a default value of -1, then I see no problem with converting it to Argument Clinic using a default value of -1. If you claim it's a "hack" then you should discuss that with the author of 1ab9978123be.

@larryhastings
Copy link
Contributor

Closing as wontfix. This is not a supported use of optional groups.

@larryhastings larryhastings removed the stale Stale PR or inactive for long period of time. label May 3, 2015
@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