GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — gh-78416: Allow "|" after "$" for required keyword-only arguments by serhiy-storchaka · Pull Request #155331 · python/cpython

Conversation

@serhiy-storchaka

@serhiy-storchaka serhiy-storchaka commented Aug 7, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

PyArg_ParseTupleAndKeywords() supports only three of the four kinds of parameters: keyword-only arguments are either all required ("OO$OO") or all optional ("O|O$O"), so f(a, b=None, *, c, d=None) cannot be expressed.

This is one of three alternative implementations, made for comparison as suggested in the issue; this one adds no new syntax at all (taleinat's proposal). | may now follow $, ending the required keyword-only arguments: "O|O$O|O" corresponds to f(a, b=None, *, c, d=None). Without a | after it, $ keeps its current meaning exactly. Every format it gives meaning to is a SystemError today, so nothing that works can change.

Argument Clinic uses the trailing | when $ alone cannot express the signature, so such functions can now use the limited C API, and it no longer rejects a required keyword-only parameter after an optional positional one.

It is the smallest change to Python/getargs.c of the three, because the "$ before |" error disappears entirely. Against that: whether an argument after $ is required now depends on text further right, so the scanner must look ahead; and a forgotten trailing | silently makes required keyword-only arguments optional, since "O|O$O|" is f(a, b=None, *, c) while "O|O$O" is f(a, b=None, *, c=None) — both legal, neither diagnosable.

The other two alternatives: #155329, #155330.

  • Issue: PyArg_ParseTupleAndKeywords: support required keyword arguments #78416

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@bedevere-app bedevere-app Bot mentioned this pull request Aug 7, 2026
PyArg_ParseTupleAndKeywords: support required keyword arguments #78416
Open
This was referenced Aug 7, 2026
gh-78416: Add the "%" format unit for required keyword-only arguments #155329
Draft
gh-78416: Add the "$$" format unit for required keyword-only arguments #155330
Draft
@read-the-docs-community

read-the-docs-community Bot commented Aug 7, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

Documentation build overview

📚 cpython-previews | 🛠️ Build #33962527 | 📁 Comparing 625e7b2 against main (7c653e2)

  🔍 Preview build  

4 files changed
± c-api/arg.html
± library/test.html
± whatsnew/3.16.html
± whatsnew/changelog.html
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@serhiy-storchaka
pythongh-78416: Support required keyword-only arguments in PyArg_Pars…
625e7b2
…eTupleAndKeywords()

"|" can now be specified after "$" to end the required keyword-only
arguments, so that they can be mixed with optional arguments.  The
keyword-only arguments are required until "|", if it follows, and inherit
the state of the positional arguments otherwise.

Argument Clinic uses this if "$" alone cannot express the signature, so
that such functions can now use the limited C API.  It also no longer
rejects a required keyword-only parameter after an optional positional one.
@serhiy-storchaka
serhiy-storchaka force-pushed the getargs-required-kwonly-bar branch from 7805b1c to 625e7b2 Compare August 7, 2026 15:27
@github-actions

github-actions Bot commented Nov 6, 2026

Copy link
Copy Markdown

This PR is stale because it has been open for 90 days with no activity.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@github-actions github-actions Bot added the stale Stale PR or inactive for long period of time. label Nov 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@ericsnowcurrently ericsnowcurrently Awaiting requested review from ericsnowcurrently ericsnowcurrently will be requested when the pull request is marked ready for review ericsnowcurrently is a code owner
@erlend-aasland erlend-aasland Awaiting requested review from erlend-aasland erlend-aasland will be requested when the pull request is marked ready for review erlend-aasland is a code owner
@AA-Turner AA-Turner Awaiting requested review from AA-Turner AA-Turner will be requested when the pull request is marked ready for review AA-Turner is a code owner
@ZeroIntensity ZeroIntensity Awaiting requested review from ZeroIntensity ZeroIntensity will be requested when the pull request is marked ready for review ZeroIntensity is a code owner

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

stale Stale PR or inactive for long period of time.

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

1 participant

@serhiy-storchaka
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.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.