{{ message }}
gh-122943: Add the varpos parameter in _PyArg_UnpackKeywords - #126564
Merged
serhiy-storchaka merged 1 commit intoNov 8, 2024
Merged
Conversation
serhiy-storchaka
requested review from
a team,
1st1,
abalkin,
asvetlov,
berkerpeksag,
brettcannon,
corona10,
ericsnowcurrently,
erlend-aasland,
ethanfurman,
gpshead,
kumaraditya303,
ncoghlan,
pganssle,
rhettinger,
tiran,
warsaw and
willingc
as code owners
November 8, 2024 08:07
serhiy-storchaka
removed request for
a team,
1st1,
abalkin,
asvetlov,
berkerpeksag,
brettcannon,
gpshead,
ncoghlan,
tiran and
warsaw
November 8, 2024 08:08
serhiy-storchaka
removed request for
corona10,
ericsnowcurrently,
ethanfurman,
kumaraditya303,
pganssle,
rhettinger and
willingc
November 8, 2024 08:08
Remove _PyArg_UnpackKeywordsWithVararg. Add comments for integer arguments of _PyArg_UnpackKeywords.
serhiy-storchaka
force-pushed
the
clinic-_PyArg_UnpackKeywords
branch
from
November 8, 2024 08:13
0d808e4 to
a511bc2
Compare
skirpichev
approved these changes
Nov 8, 2024
erlend-aasland
approved these changes
Nov 8, 2024
erlend-aasland
left a comment
Contributor
There was a problem hiding this comment.
Neat. Consider this style amendment for IMO slightly more readable generated code:
diff
diff --git a/Tools/clinic/libclinic/parse_args.py b/Tools/clinic/libclinic/parse_args.py
index 8b7afbcf3e4..8d1714b1ebe 100644
--- a/Tools/clinic/libclinic/parse_args.py
+++ b/Tools/clinic/libclinic/parse_args.py
@@ -695,13 +695,21 @@ def parse_general(self, clang: CLanguage) -> None:
if has_optional_kw:
self.declarations += "\nPy_ssize_t noptargs = %s + (kwargs ? PyDict_GET_SIZE(kwargs) : 0) - %d;" % (nargs, self.min_pos + self.min_kw_only)
unpack_args = '_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL'
- parser_code = [libclinic.normalize_snippet(f"""
- {argsname} = _PyArg_UnpackKeywords({unpack_args}, &_parser,
- /*minpos*/ {self.min_pos}, /*maxpos*/ {self.max_pos}, /*minkw*/ {self.min_kw_only}, /*varpos*/ {1 if self.varpos else 0}, argsbuf);
+ snippet = f"""
+ {argsname} = _PyArg_UnpackKeywords(
+ {unpack_args}, &_parser,
+ /*minpos*/ {self.min_pos},
+ /*maxpos*/ {self.max_pos},
+ /*minkw*/ {self.min_kw_only},
+ /*varpos*/ {1 if self.varpos else 0},
+ argsbuf
+ );
if (!{argsname}) {{{{
goto exit;
}}}}
- """, indent=4)]
+ """
+ snippet = libclinic.normalize_snippet(snippet, indent=4)
+ parser_code = [snippet]
if self.requires_defining_class:
self.flags = 'METH_METHOD|' + self.flags
Member
Contributor
We already do auto-formatting of clinic output1; see Footnotes
|
Member
Author
picnixz
pushed a commit
to picnixz/cpython
that referenced
this pull request
Dec 8, 2024
…ythonGH-126564) Remove _PyArg_UnpackKeywordsWithVararg. Add comments for integer arguments of _PyArg_UnpackKeywords.
ebonnal
pushed a commit
to ebonnal/cpython
that referenced
this pull request
Jan 12, 2025
…ythonGH-126564) Remove _PyArg_UnpackKeywordsWithVararg. Add comments for integer arguments of _PyArg_UnpackKeywords.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Remove _PyArg_UnpackKeywordsWithVararg.
Add comments for integer arguments of _PyArg_UnpackKeywords.
This is a follow up of #122945. It was not included in #122945 to minimize the diff.