Repository: pyca/cryptography

Issue:
Python 3.6 incompatibility because of getargspec
Hi, on testing pywikibot on 3.6 I noticed that your package uses `inspect.getargspec` which has been removed in 3.6 after it has been deprecated in 3.5 (although the documentation mentions it has been deprecated since Python 3).

I know that Python 3.6 hasn't been released yet but I just wanted to let you know so you have enough time to prevent issues before it is released.

Here the Travis build: https://travis-ci.org/xZise/pywikibot-core/jobs/82446934



Discussion:
Thanks for the report! We use it here (https://github.com/pyca/cryptography/blob/master/src/cryptography/utils.py#L70) to check interface implementations, so we'll need to determine what the new approach needs to be.

I think we just need to call `getfullargspec` when it's available. I've got
a patch I'll send up when I'm back on my other machine.

On Tue, Sep 29, 2015 at 8:59 AM, Paul Kehrer notifications@github.com
wrote:

> Thanks for the report! We use it here (
> https://github.com/pyca/cryptography/blob/master/src/cryptography/utils.py#L70)
> to check interface implementations, so we'll need to determine what the new
> approach needs to be.
> 
> —
> Reply to this email directly or view it on GitHub
> https://github.com/pyca/cryptography/issues/2382#issuecomment-144050782.

## 

"I disapprove of what you say, but I will defend to the death your right to
say it." -- Evelyn Beatrice Hall (summarizing Voltaire)
"The people's good is the highest law." -- Cicero
GPG Key fingerprint: 125F 5C67 DFE9 4084

@alex `getfullargspec()` is deprecated as well. The recommendation in the docs is to use `signature()` instead.

I love chains of deprecations!

On Tue, Sep 29, 2015 at 9:35 AM, Terry Chia notifications@github.com
wrote:

> @alex https://github.com/alex getfullargspec() is deprecated as well.
> The recommendation in the docs is to use signature() instead.
> 
> —
> Reply to this email directly or view it on GitHub
> https://github.com/pyca/cryptography/issues/2382#issuecomment-144060207.

## 

"I disapprove of what you say, but I will defend to the death your right to
say it." -- Evelyn Beatrice Hall (summarizing Voltaire)
"The people's good is the highest law." -- Cicero
GPG Key fingerprint: 125F 5C67 DFE9 4084

Complicating this issue is that Python 2.7 doesn't have `signature()` (or `getfullargspec()` even).

Now on pywikibot we have solved that problem by replicating the result on Python 3.5+ by using `signature()` wikimedia/pywikibot-core@baf31f1b. And for the other way around I asked the devs of `future` PythonCharmers/python-future#157, although nothing has happened there and I'm not sure what you policies regarding third party packages is (we use `future` a lot to support Python 2.6).


Resolving patch:
diff --git a/src/cryptography/utils.py b/src/cryptography/utils.py
--- a/src/cryptography/utils.py
+++ b/src/cryptography/utils.py
@@ -58,6 +58,12 @@ class InterfaceNotImplemented(Exception):
     pass
 
 
+if hasattr(inspect, "signature"):
+    signature = inspect.signature
+else:
+    signature = inspect.getargspec
+
+
 def verify_interface(iface, klass):
     for method in iface.__abstractmethods__:
         if not hasattr(klass, method):
@@ -67,13 +73,13 @@ def verify_interface(iface, klass):
         if isinstance(getattr(iface, method), abc.abstractproperty):
             # Can't properly verify these yet.
             continue
-        spec = inspect.getargspec(getattr(iface, method))
-        actual = inspect.getargspec(getattr(klass, method))
-        if spec != actual:
+        sig = signature(getattr(iface, method))
+        actual = signature(getattr(klass, method))
+        if sig != actual:
             raise InterfaceNotImplemented(
                 "{0}.{1}'s signature differs from the expected. Expected: "
                 "{2!r}. Received: {3!r}".format(
-                    klass, method, spec, actual
+                    klass, method, sig, actual
                 )
             )
 


Test patch: