Skip to content

Commit 33838fe

Browse files
authored
gh-104050: Argument clinic: annotate post_parsing() and cleanup() (#107225)
1 parent 70dc009 commit 33838fe

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

Tools/clinic/clinic.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3664,10 +3664,12 @@ def converter_init(
36643664
if NoneType in accept and self.c_default == "Py_None":
36653665
self.c_default = "NULL"
36663666

3667-
def post_parsing(self):
3667+
def post_parsing(self) -> str:
36683668
if self.encoding:
36693669
name = self.name
36703670
return f"PyMem_FREE({name});\n"
3671+
else:
3672+
return ""
36713673

36723674
def parse_arg(self, argname: str, displayname: str) -> str:
36733675
if self.format_unit == 's':
@@ -3845,8 +3847,10 @@ def converter_init(
38453847
fail("Py_UNICODE_converter: illegal 'accept' argument " + repr(accept))
38463848
self.c_default = "NULL"
38473849

3848-
def cleanup(self):
3849-
if not self.length:
3850+
def cleanup(self) -> str:
3851+
if self.length:
3852+
return ""
3853+
else:
38503854
return """\
38513855
PyMem_Free((void *){name});
38523856
""".format(name=self.name)

0 commit comments

Comments
 (0)