[Python-checkins] gh-104050: Argument clinic: annotate `post_parsing()` and `cleanup()` (#107225)
AlexWaygood
webhook-mailer at python.org
Tue Jul 25 18:33:06 EDT 2023
https://github.com/python/cpython/commit/33838fedf7ed6ee907a49d042f8fa123178a1f9c
commit: 33838fedf7ed6ee907a49d042f8fa123178a1f9c
branch: main
author: Alex Waygood <Alex.Waygood at Gmail.com>
committer: AlexWaygood <Alex.Waygood at Gmail.com>
date: 2023-07-25T23:33:03+01:00
summary:
gh-104050: Argument clinic: annotate `post_parsing()` and `cleanup()` (#107225)
files:
M Tools/clinic/clinic.py
diff --git a/Tools/clinic/clinic.py b/Tools/clinic/clinic.py
index c46c6860e45d2..d9e893f1f1d35 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)
More information about the Python-checkins
mailing list