gh-132753: Argument Clinic: Fix support of c_default for the bool converter (GH-132754)

This commit is contained in:
Serhiy Storchaka 2025-04-21 02:21:29 +03:00 committed by GitHub
parent dc4a7077ac
commit 78cfee6f09
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 86 additions and 2 deletions

View file

@ -30,7 +30,8 @@ class bool_converter(CConverter):
fail(f"bool_converter: illegal 'accept' argument {accept!r}")
if self.default is not unspecified and self.default is not unknown:
self.default = bool(self.default)
self.c_default = str(int(self.default))
if self.c_default in {'Py_True', 'Py_False'}:
self.c_default = str(int(self.default))
def parse_arg(self, argname: str, displayname: str, *, limited_capi: bool) -> str | None:
if self.format_unit == 'i':