gh-85283: Fix Argument Clinic for md5 extension (#110976)

Limited C API supports the defining class under some conditions.
This commit is contained in:
Victor Stinner 2023-10-17 13:46:16 +02:00 committed by GitHub
parent 4dba0a6d87
commit 054f496bd4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 5 deletions

View 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]*/

View file

@ -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 = ")"