diff --git a/Tools/clinic/clinic.py b/Tools/clinic/clinic.py index c46c6860e45d27..d9e893f1f1d353 100755 --- a/Tools/clinic/clinic.py +++ b/Tools/clinic/clinic.py @@ -3664,10 +3664,12 @@ def converter_init( if NoneType in accept and self.c_default == "Py_None": self.c_default = "NULL" - def post_parsing(self): + def post_parsing(self) -> str: if self.encoding: name = self.name return f"PyMem_FREE({name});\n" + else: + return "" def parse_arg(self, argname: str, displayname: str) -> str: if self.format_unit == 's': @@ -3845,8 +3847,10 @@ def converter_init( fail("Py_UNICODE_converter: illegal 'accept' argument " + repr(accept)) self.c_default = "NULL" - def cleanup(self): - if not self.length: + def cleanup(self) -> str: + if self.length: + return "" + else: return """\ PyMem_Free((void *){name}); """.format(name=self.name)