Skip to content

Commit 0d808e4

Browse files
gh-122943: Add the varpos parameter in _PyArg_UnpackKeywords
Remove _PyArg_UnpackKeywordsWithVararg. Add comments for integer arguments of _PyArg_UnpackKeywords.
1 parent 06a8b0b commit 0d808e4

File tree

93 files changed

+1219
-684
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

93 files changed

+1219
-684
lines changed

Include/internal/pycore_modsupport.h

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ PyAPI_FUNC(int) _PyArg_ParseStackAndKeywords(
7676
...);
7777

7878
// Export for 'math' shared extension
79-
PyAPI_FUNC(PyObject * const *) _PyArg_UnpackKeywordsEx(
79+
PyAPI_FUNC(PyObject * const *) _PyArg_UnpackKeywords(
8080
PyObject *const *args,
8181
Py_ssize_t nargs,
8282
PyObject *kwargs,
@@ -87,17 +87,12 @@ PyAPI_FUNC(PyObject * const *) _PyArg_UnpackKeywordsEx(
8787
int minkw,
8888
int varpos,
8989
PyObject **buf);
90-
#define _PyArg_UnpackKeywords(args, nargs, kwargs, kwnames, parser, minpos, maxpos, minkw, buf) \
90+
#define _PyArg_UnpackKeywords(args, nargs, kwargs, kwnames, parser, minpos, maxpos, minkw, varpos, buf) \
9191
(((minkw) == 0 && (kwargs) == NULL && (kwnames) == NULL && \
92-
(minpos) <= (nargs) && (nargs) <= (maxpos) && (args) != NULL) ? \
92+
(minpos) <= (nargs) && ((varpos) || (nargs) <= (maxpos)) && (args) != NULL) ? \
9393
(args) : \
94-
_PyArg_UnpackKeywordsEx((args), (nargs), (kwargs), (kwnames), (parser), \
95-
(minpos), (maxpos), (minkw), 0, (buf)))
96-
#define _PyArg_UnpackKeywordsWithVararg(args, nargs, kwargs, kwnames, parser, minpos, maxpos, minkw, buf) \
97-
(((minkw) == 0 && (kwargs) == NULL && (kwnames) == NULL && \
98-
(minpos) <= (nargs) && (args) != NULL) ? (args) : \
99-
_PyArg_UnpackKeywordsEx((args), (nargs), (kwargs), (kwnames), (parser), \
100-
(minpos), (maxpos), (minkw), 1, (buf)))
94+
_PyArg_UnpackKeywords((args), (nargs), (kwargs), (kwnames), (parser), \
95+
(minpos), (maxpos), (minkw), (varpos), (buf)))
10196

10297
#ifdef __cplusplus
10398
}

Lib/test/clinic.test.c

Lines changed: 93 additions & 62 deletions
Large diffs are not rendered by default.

Lib/test/test_call.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ def test_varargs17_kw(self):
168168
print, 0, sep=1, end=2, file=3, flush=4, foo=5)
169169

170170
def test_varargs18_kw(self):
171-
# _PyArg_UnpackKeywordsWithVararg()
171+
# _PyArg_UnpackKeywords() with varpos
172172
msg = r"invalid keyword argument for print\(\)$"
173173
with self.assertRaisesRegex(TypeError, msg):
174174
print(0, 1, **{BadStr('foo'): ','})

Modules/_ctypes/clinic/_ctypes.c.h

Lines changed: 23 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Modules/_ctypes/clinic/cfield.c.h

Lines changed: 3 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Modules/_io/clinic/_iomodule.c.h

Lines changed: 5 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Modules/_io/clinic/bufferedio.c.h

Lines changed: 15 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Modules/_io/clinic/bytesio.c.h

Lines changed: 3 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Modules/_io/clinic/fileio.c.h

Lines changed: 11 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Modules/_io/clinic/iobase.c.h

Lines changed: 5 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)