]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-85283: Fix Argument Clinic for md5 extension (#110976)
authorVictor Stinner <vstinner@python.org>
Tue, 17 Oct 2023 11:46:16 +0000 (13:46 +0200)
committerGitHub <noreply@github.com>
Tue, 17 Oct 2023 11:46:16 +0000 (13:46 +0200)
Limited C API supports the defining class under some conditions.

Modules/clinic/md5module.c.h
Tools/clinic/clinic.py

index 11db7952c5ce6abbe9e89bee706e8476faa6f9da..1d98c574929f6f78856a37bb51f65abb819dc12b 100644 (file)
@@ -9,7 +9,7 @@ PyDoc_STRVAR(MD5Type_copy__doc__,
 "Return a copy of the hash object.");
 
 #define MD5TYPE_COPY_METHODDEF    \
-    {"copy", _PyCFunction_CAST(MD5Type_copy), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, MD5Type_copy__doc__},
+    {"copy", (PyCFunction)(void(*)(void))MD5Type_copy, METH_METHOD|METH_FASTCALL|METH_KEYWORDS, MD5Type_copy__doc__},
 
 static PyObject *
 MD5Type_copy_impl(MD5object *self, PyTypeObject *cls);
@@ -97,4 +97,4 @@ _md5_md5(PyObject *module, PyObject *args, PyObject *kwargs)
 exit:
     return return_value;
 }
-/*[clinic end generated code: output=015f7613e3a9bb93 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=81702ec915f36236 input=a9049054013a1b77]*/
index a54986506066f4129088814c11cc3139fd339816..3112e7cb286f9d8eef0bec9104a45a60965f44d0 100755 (executable)
@@ -1199,7 +1199,7 @@ class CLanguage(Language):
 
         fastcall = not new_or_init
         limited_capi = clinic.limited_capi
-        if limited_capi and (requires_defining_class or pseudo_args or
+        if limited_capi and (pseudo_args or
                 (any(p.is_optional() for p in parameters) and
                  any(p.is_keyword_only() and not p.is_optional() for p in parameters)) or
                 any(c.broken_limited_capi for c in converters)):
@@ -1642,12 +1642,11 @@ class CLanguage(Language):
                                             declarations=declarations)
 
 
+        methoddef_cast_end = ""
         if flags in ('METH_NOARGS', 'METH_O', 'METH_VARARGS'):
             methoddef_cast = "(PyCFunction)"
-            methoddef_cast_end = ""
         elif limited_capi:
             methoddef_cast = "(PyCFunction)(void(*)(void))"
-            methoddef_cast_end = ""
         else:
             methoddef_cast = "_PyCFunction_CAST("
             methoddef_cast_end = ")"