Skip to content

Commit a511bc2

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 a511bc2

File tree

94 files changed

+1220
-685
lines changed

Some content is hidden

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

94 files changed

+1220
-685
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'): ','})

Lib/test/test_clinic.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2703,7 +2703,7 @@ def test_cli_force(self):
27032703
# Verify by checking the checksum.
27042704
checksum = (
27052705
"/*[clinic end generated code: "
2706-
"output=0acbef4794cb933e input=9543a8d2da235301]*/\n"
2706+
"output=00512eb783a9b748 input=9543a8d2da235301]*/\n"
27072707
)
27082708
with open(fn, encoding='utf-8') as f:
27092709
generated = f.read()

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.

Modules/_io/clinic/stringio.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.

0 commit comments

Comments
 (0)