Repository: numba/numba

Issue:
Remove deprecated use of inspect.getargspec 
(From mailing list: https://groups.google.com/a/continuum.io/d/msgid/numba-users/83ccf8f9-fb9f-4d76-8229-0d89608fe816%40continuum.io?utm_medium=email&utm_source=footer)

On python 3.6.7, numba 0.43.1, MacOS, usage of dufunc is causing a DeprecationWarning:

```
/home/build/.local/share/virtualenvs/work-WgJkZa2_/lib/python3.6/site-packages/numba/npyufunc/dufunc.py:86
  /home/build/.local/share/virtualenvs/work-WgJkZa2_/lib/python3.6/site-packages/numba/npyufunc/dufunc.py:86: DeprecationWarning: inspect.getargspec() is deprecated, use inspect.signature() or inspect.getfullargspec()
    super(DUFunc, self).__init__(dispatcher, **kws)
  /home/build/.local/share/virtualenvs/work-WgJkZa2_/lib/python3.6/site-packages/numba/npyufunc/dufunc.py:86: DeprecationWarning: inspect.getargspec() is deprecated, use inspect.signature() or inspect.getfullargspec()
    super(DUFunc, self).__init__(dispatcher, **kws)
```

The warning is corresponding to the lines at https://github.com/numba/numba/blob/ca731bf94bc6b23cdc865470b9e98ef647c0b1c8/numba/npyufunc/_internal.c#L166-L174


Discussion:
It seems there are a couple more usages but I don't think they're the ones contributing to the warnings in our test suite
```
2019-04-11T04:14:07.1452476Z   C:\Miniconda3\envs\pricing\lib\site-packages\numba\npyufunc\dufunc.py:86: DeprecationWarning: inspect.getargspec() is deprecated since Python 3.0, use inspect.signature() or inspect.getfullargspec()
2019-04-11T04:14:07.1452563Z 
2019-04-11T04:14:07.1452648Z     super(DUFunc, self).__init__(dispatcher, **kws)
2019-04-11T04:14:07.1452711Z 
2019-04-11T04:14:07.1452783Z 
```

https://github.com/numba/numba/blob/b3afbb876a3a789e431554ef4d80ba2bcf982439/numba/npyufunc/ufuncbuilder.py#L243

https://github.com/numba/numba/blob/c5461dd295663559b55f7e59280df9317062887c/numba/tracing.py#L156

@dhirschfeld is still relevant or has it been fixed with #3935 ?
That was a different warning. AFAIK this is still relevant. Haven't yet tested on the latest though... 
@dhirschfeld O.K. - I just had a quick look for a minimal reproducer but failed to find it. Did it miss it? May I kindly request that you point me in the right direction? Thanks!
Still seeing this in our CI with:
```
numba              pkgs/main/win-64::numba-0.43.1-py37hf9181ef_0
```

***Edit:*** I see the latest is 0.44 so I'll investigate why the CI isn't picking that up...

Resolving patch:
diff --git a/numba/npyufunc/ufuncbuilder.py b/numba/npyufunc/ufuncbuilder.py
--- a/numba/npyufunc/ufuncbuilder.py
+++ b/numba/npyufunc/ufuncbuilder.py
@@ -19,6 +19,7 @@
 from .wrappers import build_ufunc_wrapper, build_gufunc_wrapper
 from numba.caching import FunctionCache, NullCache
 from numba.compiler_lock import global_compiler_lock
+from numba.config import PYVERSION
 
 
 class UFuncTargetOptions(TargetOptions):
@@ -240,7 +241,10 @@ def build_ufunc(self):
             datlist = [None] * len(ptrlist)
 
             if cres is None:
-                argspec = inspect.getargspec(self.py_func)
+                if PYVERSION >= (3, 0):
+                    argspec = inspect.getfullargspec(self.py_func)
+                else:
+                    argspec = inspect.getargspec(self.py_func)
                 inct = len(argspec.args)
             else:
                 inct = len(cres.signature.args)
diff --git a/numba/tracing.py b/numba/tracing.py
--- a/numba/tracing.py
+++ b/numba/tracing.py
@@ -72,7 +72,7 @@ def create_events(fname, spec, args, kwds):
     leave = ['<< ', tls.indent * ' ', fname]
     return enter, leave
 
-    
+
 def dotrace(*args, **kwds):
     """Function decorator to trace a function's entry and exit.
 
@@ -97,7 +97,7 @@ def wrapper(*args, **kwds):
                 return func(*args, **kwds)
 
             fname, ftype = find_function_info(func, spec, args)
-            
+
             try:
                 tls.tracing = True
                 enter, leave = create_events(fname, spec, args, kwds)
@@ -153,9 +153,12 @@ def wrapper(*args, **kwds):
         elif type(func) == property:
             raise NotImplementedError
 
-        spec = inspect.getargspec(func)
+        if config.PYVERSION >= (3, 0):
+            spec = inspect.getfullargspec(func)
+        else:
+            spec = inspect.getargspec(func)
         return rewrap(wraps(func)(wrapper))
-    
+
     arg0 = len(args) and args[0] or None
     # not supported yet...
     if recursive:
@@ -169,7 +172,7 @@ def wrapper(*args, **kwds):
             for n, f in inspect.getmembers(arg0, lambda x: (inspect.isfunction(x) or
                                                             inspect.ismethod(x))):
                 setattr(arg0, n, decorator(f))
-                
+
 
     if callable(arg0) or type(arg0) in (classmethod, staticmethod):
         return decorator(arg0)
@@ -184,7 +187,7 @@ def wrapper(*args, **kwds):
         if arg0.fdel:
             pdel = decorator(arg0.fdel)
         return property(pget, pset, pdel)
-        
+
     else:
         return decorator
 


Test patch: