Skip to content

gh-162098: add initialization for '_length' variable to Argument Clinic - #162100

Open
samitistfobos-dev wants to merge 2 commits into
python:mainfrom
samitistfobos-dev:main
Open

samitistfobos-dev wants to merge 2 commits into
python:mainfrom
samitistfobos-dev:main

Conversation

@samitistfobos-dev

@samitistfobos-dev samitistfobos-dev commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Problem:
Argument Clinic rendered the adjacent "length" variable of an optional length-bearing string parameter ("s#", "y#", "z#", "u#", "Z#") without an initializer. The parser only writes *_length when the argument is actually passed, so an omitted argument left the variable undefined and the impl function received an arbitrary buffer size
(Modules/clinic/_testclinic.c.h:1531, c_length).
Solution: Initialize the length variable from the parameter's default value in Tools/clinic/libclinic/converter.py: a new CConverter.length_c_default() hook, UTF-8 byte length for str defaults, 0 for None/NULL; regenerate the affected clinic files and add regression tests for calls with omitted arguments.

Signed-off-by: a.burlakov ([email protected])

@python-cla-bot

python-cla-bot Bot commented Nov 16, 2026 •

Copy link
Copy Markdown

All commit authors signed the Contributor License Agreement.

CLA signed

Problem:
Argument Clinic rendered the adjacent "length" variable of an optional
length-bearing string parameter ("s#", "y#", "z#", "u#", "Z#") without an
initializer. The parser only writes *<name>_length when the argument is
actually passed, so an omitted argument left the variable undefined and the
impl function received an arbitrary buffer size
(Modules/clinic/_testclinic.c.h:1531, c_length).
Solution: Initialize the length variable from the parameter's default value in
Tools/clinic/libclinic/converter.py: a new CConverter.length_c_default() hook,
UTF-8 byte length for str defaults, 0 for None/NULL; regenerate the affected
clinic files and add regression tests for calls with omitted arguments.
Signed-off-by: a.burlakov ([email protected])
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