[issue20141] Argument Clinic: broken support for 'O!'
New submission from Serhiy Storchaka: First, the documentation says that syntax for 'O!' conversion is object(type='name_of_Python_type'), but actually the type argument should be the name of C structure which represents Python type. I.e. object(type='list') is rejected, and object(type='PyList_Type') is accepted. Second, from this declaration /*[clinic] module spam spam.ham items: object(type='PyList_Type') / [clinic]*/ Argument Clinic generates following parsing code: if (!PyArg_ParseTuple(args, "O!:ham", PyList_Type, &items)) goto exit; It is wrong, should be &PyList_Type. ---------- assignee: docs@python components: Build, Documentation messages: 207430 nosy: docs@python, larry, serhiy.storchaka priority: release blocker severity: normal status: open title: Argument Clinic: broken support for 'O!' type: crash versions: Python 3.4 _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue20141> _______________________________________
Larry Hastings added the comment: So a documentation error and having to manually specify "&" at the front of your string means it's "broken"? Nevertheless, I'll take a look at it. ---------- _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue20141> _______________________________________
Serhiy Storchaka added the comment: You can't manually specify "&" at the front of the name. ---------- _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue20141> _______________________________________
Changes by Serhiy Storchaka <storchaka@gmail.com>: Added file: http://bugs.python.org/file33325/spammodule.c _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue20141> _______________________________________
Larry Hastings added the comment: Actually, the documentation (the "howto") states: Note that object() must explicitly support each Python type you specify for the type argument. Currently it only supports str. It should be easy to add more, just edit Tools/clinic/clinic.py, search for O! in the text, and add more entries to the dict mapping types to strings just above it. Maybe this is a bad API. But it's not broken. ---------- _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue20141> _______________________________________
participants (2)
-
Larry Hastings
-
Serhiy Storchaka