Skip to content

Commit

Permalink
Use callable() to check callable in ldms.Xprt (ldms.pyx)
Browse files Browse the repository at this point in the history
The `isinstance(cb, types.FunctionType)` check does not cover all
callables. If the application supplies a method as `cb`, the
`isinstance` check failed. This patch modifies the condition to use
`callable()` check instead to cover all callable types.
  • Loading branch information
narategithub committed Jul 12, 2024
1 parent 02c899f commit 2a5e483
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion ldms/python/ldms.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -3209,7 +3209,7 @@ cdef class Xprt(object):
import types
cdef int rc
cdef timespec ts
if not isinstance(cb, types.FunctionType) and cb is not None:
if cb is not None and not callable(cb):
raise TypeError("Callback argument must be callable")
self._conn_cb = cb
self._conn_cb_arg = cb_arg
Expand Down

0 comments on commit 2a5e483

Please sign in to comment.