gh-144545: Improve handling of default values in Argument Clinic#146016
Merged
serhiy-storchaka merged 6 commits intopython:mainfrom Mar 17, 2026
Merged
gh-144545: Improve handling of default values in Argument Clinic#146016serhiy-storchaka merged 6 commits intopython:mainfrom
serhiy-storchaka merged 6 commits intopython:mainfrom
Conversation
* Add the c_init_default attribute which is used to initialize the C variable
if the default is not explicitly provided.
* Add the c_default_init() method which is used to derive c_default
from default if c_default is not explicitly provided.
* Explicit c_default and py_default are now almost always have precedence
over the generated value.
* Add support for bytes literals as default values.
* Improve support for str literals as default values (support non-ASCII and
non-printable characters and special characters like backslash).
* Improved support for default values in converters "char" and
"int(accept={str})".
* Add support for non-NULL default values in converter "Py_buffer".
* Improve error handling for invalid default values.
|
Thanks @serhiy-storchaka for the PR 🌮🎉.. I'm working now to backport this PR to: 3.14. |
|
Sorry, @serhiy-storchaka, I could not cleanly backport this to |
serhiy-storchaka
added a commit
to serhiy-storchaka/cpython
that referenced
this pull request
Mar 17, 2026
…t Clinic (pythonGH-146016) * Add the c_init_default attribute which is used to initialize the C variable if the default is not explicitly provided. * Add the c_default_init() method which is used to derive c_default from default if c_default is not explicitly provided. * Explicit c_default and py_default are now almost always have precedence over the generated value. * Add support for bytes literals as default values. * Improve support for str literals as default values (support non-ASCII and non-printable characters and special characters like backslash or quotes). * Fix support for str and bytes literals containing trigraphs, "/*" and "*/". * Improve support for default values in converters "char" and "int(accept={str})". * Converter "int(accept={str})" now requires 1-character string instead of integer as default value. * Add support for non-None default values in converter "Py_buffer": NULL, str and bytes literals. * Improve error handling for invalid default values. * Rename Null to NullType for consistency. (cherry picked from commit 99e2c5e) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
|
GH-146052 is a backport of this pull request to the 3.14 branch. |
serhiy-storchaka
added a commit
that referenced
this pull request
Mar 17, 2026
…ic (GH-146016) (GH-146052) * Add the c_init_default attribute which is used to initialize the C variable if the default is not explicitly provided. * Add the c_default_init() method which is used to derive c_default from default if c_default is not explicitly provided. * Explicit c_default and py_default are now almost always have precedence over the generated value. * Add support for bytes literals as default values. * Improve support for str literals as default values (support non-ASCII and non-printable characters and special characters like backslash or quotes). * Fix support for str and bytes literals containing trigraphs, "/*" and "*/". * Improve support for default values in converters "char" and "int(accept={str})". * Converter "int(accept={str})" now requires 1-character string instead of integer as default value. * Add support for non-None default values in converter "Py_buffer": NULL, str and bytes literals. * Improve error handling for invalid default values. * Rename Null to NullType for consistency. (cherry picked from commit 99e2c5e)
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.
Uh oh!
There was an error while loading. Please reload this page.