Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

gh-144175: Add PyArg_ParseVector() function#144283

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
vstinner wants to merge5 commits intopython:main
base:main
Choose a base branch
Loading
fromvstinner:parse_vector

Conversation

@vstinner
Copy link
Member

@vstinnervstinner commentedJan 27, 2026
edited by github-actionsbot
Loading

@vstinner
Copy link
MemberAuthor

The change doesn't include tests because my plan is to write a following PR to rename_PyArg_ParseStack() toPyArg_ParseVector(). Many modules using Argument Clinic are calling_PyArg_ParseStack(). I prefer to write a separated PR since it changes a lot of code and so is harder to review.

vstinnerand others added4 commitsJanuary 28, 2026 11:24
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
@vstinner
Copy link
MemberAuthor

Ok, I completed the PR to add alsoPyArg_ParseVectorAndKeywords() function. The PR is now ready for review :-)

@vstinner
Copy link
MemberAuthor

I propose the following API:

intPyArg_ParseVector(PyObject*const*args,Py_ssize_tnargs,constchar*format,    ...);intPyArg_ParseVectorAndKeywords(PyObject*const*args,Py_ssize_tnargs,PyObject*kwnames,constchar*format,char*const*kwlist,    ...);

Py_ssize_t nargs,
PyObject *kwnames,
constchar *format,
PY_CXX_CONSTchar *const *kwlist,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Any reason to have PY_CXX_CONST? why now alwaysconst char *const *kwlist? (are there occurrences where we don't have a const?)

Copy link
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Ifkwlist is declared asconst char * const *kwlist, I get a compiler error on the following code:

intarg,arg2=0;char*kwlist[]= {"arg","arg2",NULL};if (!PyArg_ParseVectorAndKeywords(args,nargs,kwnames,"i|i",kwlist,&arg,&arg2)) {returnNULL;    }

Error:

./Modules/_testcapimodule.c: In function 'fastcall_kwnames':./Modules/_testcapimodule.c:2603:68: error: passing argument 5 of 'PyArg_ParseVectorAndKeywords' from incompatible pointer type [-Wincompatible-pointer-types] 2603 |     if (!PyArg_ParseVectorAndKeywords(args, nargs, kwnames, "i|i", kwlist,      |                                                                    ^~~~~~      |                                                                    |      |                                                                    char **In file included from ./Include/modsupport.h:153,                 from ./Include/Python.h:132,                 from ./Modules/_testcapi/parts.h:25,                 from ./Modules/_testcapimodule.c:13:./Include/cpython/modsupport.h:15:25: note: expected 'const char * const*' but argument is of type 'char **'   15 |     const char * const *kwlist,      |     ~~~~~~~~~~~~~~~~~~~~^~~~~~

PY_CXX_CONST is also used forkwlist byPyArg_ParseTupleAndKeywords() for example.

PY_CXX_CONST is only defined asconst if building C++.

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@picnixzpicnixzpicnixz approved these changes

@ericsnowcurrentlyericsnowcurrentlyAwaiting requested review from ericsnowcurrentlyericsnowcurrently is a code owner

@AA-TurnerAA-TurnerAwaiting requested review from AA-TurnerAA-Turner is a code owner

Assignees

No one assigned

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

2 participants

@vstinner@picnixz

[8]ページ先頭

©2009-2026 Movatter.jp