8000 gh-122943: Rework support of var-positional parameter in Argument Clinic by serhiy-storchaka · Pull Request #122945 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-122943: Rework support of var-positional parameter in Argument Clinic #122945

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 17 commits into from
Nov 7, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Polishing.
  • Loading branch information
serhiy-storchaka committed Nov 6, 2024
commit e38d94ed7a1852ddf1b9d640a7653c6e7bb26a09
10 changes: 5 additions & 5 deletions Modules/clinic/_testclinic.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 1 addition & 3 deletions Modules/gcmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -230,9 +230,7 @@ gc_get_referrers_impl(PyObject *module, PyObject *objs)
}

PyInterpreterState *interp = _PyInterpreterState_GET();
PyObject *result = _PyGC_GetReferrers(interp, objs);

return result;
return _PyGC_GetReferrers(interp, objs);
}

/* Append obj to list; return true if error (out of memory), false if OK. */
Expand Down
2 changes: 1 addition & 1 deletion Tools/clinic/libclinic/converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ def render(self, parameter: Parameter, data: CRenderData) -> None:
def length_name(self) -> str:
"""Computes the name of the associated "length" variable."""
assert self.length is not None
return self.parser_name.removeprefix(libclinic.CLINIC_PREFIX) + "_length"
return self.name + "_length"

# Why is this one broken out separately?
# For "positional-only" function parsing,
Expand Down
6 changes: 0 additions & 6 deletions Tools/clinic/libclinic/converters.py
Original file line number Diff line number Diff line change
Expand Up @@ -1237,9 +1237,6 @@ class varpos_tuple_converter(CConverter):
format_unit = ''
c_default = 'NULL'

def converter_init(self) -> None:
pass

def cleanup(self) -> str:
return f"""Py_XDECREF({self.parser_name});\n"""

Expand All @@ -1252,9 +1249,6 @@ class varpos_array_converter(CConverter):
length = True
c_ignored_default = ''

def converter_init(self) -> None:
pass

def parse_arg(self, argname: str, displayname: str, *, limited_capi: bool) -> str | None:
raise AssertionError('should never be called')

Expand Down
2 changes: 1 addition & 1 deletion Tools/clinic/libclinic/parse_args.py
6914
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,7 @@ def _parse_vararg(self) -> str:
size = 'nargs' if self.fastcall else 'PyTuple_GET_SIZE(args)'
if self.max_pos:
if min(self.pos_only, self.min_pos) < self.max_pos:
start = f'{start} + Py_MIN({size}, {self.max_pos})'
start = f'{size} > {self.max_pos} ? {start} + {self.max_pos} : {start}'
size = f'Py_MAX(0, {size} - {self.max_pos})'
else:
start = f'{start} + {self.max_pos}'
Expand Down
Loading
0