From a666ee4451ba61d86916e41d43bd8cf6a58b0474 Mon Sep 17 00:00:00 2001 From: Houston4444 Date: Tue, 21 May 2024 18:24:18 +0100 Subject: [PATCH] Expand one-liner python version check in _callback_num_args Apparently some combination of python 3.11 and cython [0.29?] doesn't handle the one-liner correctly, causing the `X` in `X if Y else Z` to be resolved even when Y was False. I (s0600204) never had this problem, hence the "apparently". It could be that the users reporting the problem were using the release version of 0.10.0, which doesn't have the one-liner, and thus always uses the defunct `_inspect.getargspec`, causing the issue. See also: * https://github.com/dsacre/pyliblo/issues/29 * https://github.com/Houston4444/RaySession/issues/152#issuecomment-1356896533 --- src/liblo.pyx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/liblo.pyx b/src/liblo.pyx index ed67c91..bf1e64d 100644 --- a/src/liblo.pyx +++ b/src/liblo.pyx @@ -277,8 +277,10 @@ cdef int _callback_num_args(func): """ Return the number of arguments that should be passed to callback *func*. """ - getargspec = (_inspect.getargspec if PY_VERSION_HEX < 0x03000000 - else _inspect.getfullargspec) + if PY_VERSION_HEX < 0x03000000: + getargspec = _inspect.getargspec + else: + getargspec = _inspect.getfullargspec if isinstance(func, _functools.partial): # before Python 3.4, getargspec() did't work for functools.partial,