]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
[3.14] gh-144545: Improve handling of default values in Argument Clinic (GH-146016...
authorSerhiy Storchaka <storchaka@gmail.com>
Tue, 17 Mar 2026 10:55:15 +0000 (12:55 +0200)
committerGitHub <noreply@github.com>
Tue, 17 Mar 2026 10:55:15 +0000 (10:55 +0000)
commita005f323b7c8a7c9cd06b74d02a2d3bd7134841c
treea47e00953b67dea827314f7521e65019f8c4e976
parent7ad3093d76a748af55bdb1d2e8aad3638163b017
[3.14] gh-144545: Improve handling of default values in Argument Clinic (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 99e2c5eccd2b83ac955125522a952a4ff5c7eb43)
18 files changed:
Lib/test/clinic.test.c
Lib/test/test_clinic.py
Modules/_testclinic.c
Modules/blake2module.c
Modules/clinic/_testclinic.c.h
Modules/clinic/blake2module.c.h
Modules/clinic/zlibmodule.c.h
Modules/posixmodule.c
Modules/zlibmodule.c
Objects/unicodeobject.c
Tools/c-analyzer/cpython/_parser.py
Tools/clinic/libclinic/__init__.py
Tools/clinic/libclinic/clanguage.py
Tools/clinic/libclinic/converter.py
Tools/clinic/libclinic/converters.py
Tools/clinic/libclinic/dsl_parser.py
Tools/clinic/libclinic/formatting.py
Tools/clinic/libclinic/utils.py