mirror of
https://github.com/python/cpython.git
synced 2025-08-30 13:38:43 +00:00
gh-104050: Argument clinic: annotate post_parsing()
and cleanup()
(#107225)
This commit is contained in:
parent
70dc009469
commit
33838fedf7
1 changed files with 7 additions and 3 deletions
|
@ -3664,10 +3664,12 @@ class str_converter(CConverter):
|
||||||
if NoneType in accept and self.c_default == "Py_None":
|
if NoneType in accept and self.c_default == "Py_None":
|
||||||
self.c_default = "NULL"
|
self.c_default = "NULL"
|
||||||
|
|
||||||
def post_parsing(self):
|
def post_parsing(self) -> str:
|
||||||
if self.encoding:
|
if self.encoding:
|
||||||
name = self.name
|
name = self.name
|
||||||
return f"PyMem_FREE({name});\n"
|
return f"PyMem_FREE({name});\n"
|
||||||
|
else:
|
||||||
|
return ""
|
||||||
|
|
||||||
def parse_arg(self, argname: str, displayname: str) -> str:
|
def parse_arg(self, argname: str, displayname: str) -> str:
|
||||||
if self.format_unit == 's':
|
if self.format_unit == 's':
|
||||||
|
@ -3845,8 +3847,10 @@ class Py_UNICODE_converter(CConverter):
|
||||||
fail("Py_UNICODE_converter: illegal 'accept' argument " + repr(accept))
|
fail("Py_UNICODE_converter: illegal 'accept' argument " + repr(accept))
|
||||||
self.c_default = "NULL"
|
self.c_default = "NULL"
|
||||||
|
|
||||||
def cleanup(self):
|
def cleanup(self) -> str:
|
||||||
if not self.length:
|
if self.length:
|
||||||
|
return ""
|
||||||
|
else:
|
||||||
return """\
|
return """\
|
||||||
PyMem_Free((void *){name});
|
PyMem_Free((void *){name});
|
||||||
""".format(name=self.name)
|
""".format(name=self.name)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue