Skip to content

Commit 5013406

Browse files
committed
lru: Use PyCFunction instead of PyCFunctionWithKeywords
PyMethodDef uses PyMethodDef and not PyCFunctionWithKeywords and when callback is specified as PyCFunctionWithKeywords, clang 16+ is able to detect function signature mismatch in function pointers now. Fixes lru.c:629:17: error: incompatible function pointer types initializing 'PyCFunction' (aka 'struct _object *(*)(struct _object *, struct _object *)') with an expression of type 'PyCFunctionWithKeywords' (aka 'struct _object *(*)(struct _object *, struct _object *, struct _object *)') [-Wincompatible-function-pointer-types] {"popitem", (PyCFunctionWithKeywords)LRU_popitem, METH_VARARGS | METH_KEYWORDS, ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1 error generated. Signed-off-by: Khem Raj <[email protected]>
1 parent ebd6b17 commit 5013406

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

lru.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -626,7 +626,7 @@ static PyMethodDef LRU_methods[] = {
626626
PyDoc_STR("L.setdefault(key, default=None) -> If L has key return its value, otherwise insert key with a value of default and return default")},
627627
{"pop", (PyCFunction)LRU_pop, METH_VARARGS,
628628
PyDoc_STR("L.pop(key[, default]) -> If L has key return its value and remove it from L, otherwise return default. If default is not given and key is not in L, a KeyError is raised.")},
629-
{"popitem", (PyCFunctionWithKeywords)LRU_popitem, METH_VARARGS | METH_KEYWORDS,
629+
{"popitem", (PyCFunction)LRU_popitem, METH_VARARGS | METH_KEYWORDS,
630630
PyDoc_STR("L.popitem([least_recent=True]) -> Returns and removes a (key, value) pair. The pair returned is the least-recently used if least_recent is true, or the most-recently used if false.")},
631631
{"set_size", (PyCFunction)LRU_set_size, METH_VARARGS,
632632
PyDoc_STR("L.set_size() -> set size of LRU")},

0 commit comments

Comments
 (0)