Skip to content

gh-144545: Improve handling of default values in Argument Clinic#146016

Open
serhiy-storchaka wants to merge 4 commits intopython:mainfrom
serhiy-storchaka:clinic-default-bytes-literal
Open

gh-144545: Improve handling of default values in Argument Clinic#146016
serhiy-storchaka wants to merge 4 commits intopython:mainfrom
serhiy-storchaka:clinic-default-bytes-literal

Conversation

@serhiy-storchaka
Copy link
Member

@serhiy-storchaka serhiy-storchaka commented Mar 16, 2026

  • 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.

* 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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant