Skip to content

Fix support of var-positional parameter in Argument Clinic #122688

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

Open
serhiy-storchaka opened this issue Aug 5, 2024 · 1 comment
Open

Fix support of var-positional parameter in Argument Clinic #122688

serhiy-storchaka opened this issue Aug 5, 2024 · 1 comment
Labels
3.12 only security fixes 3.13 bugs and security fixes 3.14 bugs and security fixes topic-argument-clinic

Comments

@serhiy-storchaka
Copy link
Member

serhiy-storchaka commented Aug 5, 2024

Currently Argument Clinic with a var-positional parameter is only used in few functions (print(), the TypeVar constructor (see #118814) and several set methods), so this is not well tested.

There are several bugs here:

  • Keyword-only parameters after the var-positional parameter are marked as positional-or-keyword parameters.
  • The number of required arguments for keyword-only parameters was calculated incorrectly.
  • Some invalid combination of the var-positional parameter with /, * and deprecation markers are not forbidden or produce unrelated errors.

Linked PRs

@serhiy-storchaka serhiy-storchaka added topic-argument-clinic 3.12 only security fixes 3.13 bugs and security fixes 3.14 bugs and security fixes labels Aug 5, 2024
serhiy-storchaka added a commit to serhiy-storchaka/cpython that referenced this issue Aug 5, 2024
…Clinic

* Parameters after the var-positional parameter are now keyword-only
  instead of positional-or-keyword.
* Correctly calculate min_kw_only.
* Raise errors for invalid combinations of the var-positional parameter
  with "*", "/" and deprecation markers.
serhiy-storchaka added a commit that referenced this issue Aug 9, 2024
…GH-122689)

* Parameters after the var-positional parameter are now keyword-only
  instead of positional-or-keyword.
* Correctly calculate min_kw_only.
* Raise errors for invalid combinations of the var-positional parameter
  with "*", "/" and deprecation markers.
serhiy-storchaka added a commit to serhiy-storchaka/cpython that referenced this issue Aug 9, 2024
…gument Clinic (pythonGH-122689)

* Parameters after the var-positional parameter are now keyword-only
  instead of positional-or-keyword.
* Correctly calculate min_kw_only.
* Raise errors for invalid combinations of the var-positional parameter
  with "*", "/" and deprecation markers.
(cherry picked from commit 8393608)

Co-authored-by: Serhiy Storchaka <[email protected]>
@serhiy-storchaka
Copy link
Member Author

Due to refactoring it is difficult to backport this change to 3.12. This is not such important, because these corner cases are not used in CPython for now.

But I am planning to merge it in 3.13 after release, to help backporting future bugfixes. I am currently working on significant rewriting of the code for this feature, and found few other errors.

serhiy-storchaka added a commit to serhiy-storchaka/cpython that referenced this issue Aug 11, 2024
blhsing pushed a commit to blhsing/cpython that referenced this issue Aug 22, 2024
…Clinic (pythonGH-122689)

* Parameters after the var-positional parameter are now keyword-only
  instead of positional-or-keyword.
* Correctly calculate min_kw_only.
* Raise errors for invalid combinations of the var-positional parameter
  with "*", "/" and deprecation markers.
blhsing pushed a commit to blhsing/cpython that referenced this issue Aug 22, 2024
Yhg1s pushed a commit that referenced this issue Sep 2, 2024
… Clinic (GH-122689) (#122852)

* Parameters after the var-positional parameter are now keyword-only
  instead of positional-or-keyword.
* Correctly calculate min_kw_only.
* Raise errors for invalid combinations of the var-positional parameter
  with "*", "/" and deprecation markers.
(cherry picked from commit 8393608)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.12 only security fixes 3.13 bugs and security fixes 3.14 bugs and security fixes topic-argument-clinic
Projects
None yet
Development

No branches or pull requests

1 participant