Skip to content

Commit

Permalink
Expand one-liner python version check in _callback_num_args
Browse files Browse the repository at this point in the history
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:
* dsacre#29
* Houston4444/RaySession#152 (comment)
  • Loading branch information
Houston4444 authored and s0600204 committed May 21, 2024
1 parent 7dbe6ef commit a666ee4
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/liblo.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit a666ee4

Please sign in to comment.