diff options
author | Alex Waygood <Alex.Waygood@Gmail.com> | 2023-07-25 22:33:03 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-07-25 22:33:03 (GMT) |
commit | 33838fedf7ed6ee907a49d042f8fa123178a1f9c (patch) | |
tree | 3f62e123649dde606a9baa37c67432043a30cad8 /Tools/clinic | |
parent | 70dc00946938027d5a79bcb7b65038319040144e (diff) | |
download | cpython-33838fedf7ed6ee907a49d042f8fa123178a1f9c.zip cpython-33838fedf7ed6ee907a49d042f8fa123178a1f9c.tar.gz cpython-33838fedf7ed6ee907a49d042f8fa123178a1f9c.tar.bz2 |
gh-104050: Argument clinic: annotate `post_parsing()` and `cleanup()` (#107225)
Diffstat (limited to 'Tools/clinic')
-rwxr-xr-x | Tools/clinic/clinic.py | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/Tools/clinic/clinic.py b/Tools/clinic/clinic.py index c46c686..d9e893f 100755 --- a/Tools/clinic/clinic.py +++ b/Tools/clinic/clinic.py @@ -3664,10 +3664,12 @@ class str_converter(CConverter): 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 @@ class Py_UNICODE_converter(CConverter): 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) |