From 98d4ac5adf98175b9d33841972002232d3378757 Mon Sep 17 00:00:00 2001 From: hansehv <30558081+hansehv@users.noreply.github.com> Date: Wed, 29 Jul 2020 23:56:17 +0200 Subject: [PATCH] Avoid depreciation warning --- rtmidi2.pyx | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/rtmidi2.pyx b/rtmidi2.pyx index 1b3f7a4..b0864cd 100755 --- a/rtmidi2.pyx +++ b/rtmidi2.pyx @@ -15,7 +15,10 @@ cdef extern from "Python.h": void PyEval_InitThreads() #from libc.stdlib cimport malloc, free -import inspect +try: # python 3 ? + from inspect import getfullargspec as get_args +except ImportError: # else it's python 2 + from inspect import getargspec as get_args import fnmatch # Init Python threads and GIL, because RtMidi calls Python from native threads. @@ -636,7 +639,7 @@ cpdef tuple splitchannel(int b): def _func_get_numargs(func): try: - spec = inspect.getargspec(func) + spec = get_args(func) numargs = sum(1 for a in spec.args if a is not "self") return numargs except TypeError: