diff options
author | Victor Stinner <vstinner@python.org> | 2022-05-03 18:25:41 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-05-03 18:25:41 (GMT) |
commit | b270b82f1137ff25ee263eafd31503d760f3403d (patch) | |
tree | 09a2ae5d93d47aa51f831f9fc906215095172667 /Tools/clinic | |
parent | c278474df97de310535425c207136bf26c663e0b (diff) | |
download | cpython-b270b82f1137ff25ee263eafd31503d760f3403d.zip cpython-b270b82f1137ff25ee263eafd31503d760f3403d.tar.gz cpython-b270b82f1137ff25ee263eafd31503d760f3403d.tar.bz2 |
gh-91320: Argument Clinic uses _PyCFunction_CAST() (#32210)
Replace "(PyCFunction)(void(*)(void))func" cast with
_PyCFunction_CAST(func).
Diffstat (limited to 'Tools/clinic')
-rwxr-xr-x | Tools/clinic/clinic.py | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/Tools/clinic/clinic.py b/Tools/clinic/clinic.py index f660474..bf0fe5b 100755 --- a/Tools/clinic/clinic.py +++ b/Tools/clinic/clinic.py @@ -694,7 +694,7 @@ class CLanguage(Language): methoddef_define = normalize_snippet(""" #define {methoddef_name} \\ - {{"{name}", {methoddef_cast}{c_basename}, {methoddef_flags}, {c_basename}__doc__}}, + {{"{name}", {methoddef_cast}{c_basename}{methoddef_cast_end}, {methoddef_flags}, {c_basename}__doc__}}, """) if new_or_init and not f.docstring: docstring_prototype = docstring_definition = '' @@ -1131,14 +1131,17 @@ class CLanguage(Language): if flags in ('METH_NOARGS', 'METH_O', 'METH_VARARGS'): methoddef_cast = "(PyCFunction)" + methoddef_cast_end = "" else: - methoddef_cast = "(PyCFunction)(void(*)(void))" + methoddef_cast = "_PyCFunction_CAST(" + methoddef_cast_end = ")" if f.methoddef_flags: flags += '|' + f.methoddef_flags methoddef_define = methoddef_define.replace('{methoddef_flags}', flags) methoddef_define = methoddef_define.replace('{methoddef_cast}', methoddef_cast) + methoddef_define = methoddef_define.replace('{methoddef_cast_end}', methoddef_cast_end) methoddef_ifndef = '' conditional = self.cpp.condition() |