From 44878a53ec4994730ab6e0cb2e070398794718ab Mon Sep 17 00:00:00 2001 From: Alex Gaynor Date: Tue, 29 Sep 2015 20:56:09 -0400 Subject: use signature so stuff works on 3.6 -- fixes #2382 --- src/cryptography/utils.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/cryptography/utils.py b/src/cryptography/utils.py index 237d5968..27bccbc6 100644 --- a/src/cryptography/utils.py +++ b/src/cryptography/utils.py @@ -58,6 +58,11 @@ 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,9 +72,9 @@ 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( -- cgit v1.2.3 From 685a0112306976e76125571c4cb12995df221a4a Mon Sep 17 00:00:00 2001 From: Alex Gaynor Date: Tue, 29 Sep 2015 21:06:18 -0400 Subject: sigh, fix --- src/cryptography/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cryptography/utils.py b/src/cryptography/utils.py index 27bccbc6..c91bcb2f 100644 --- a/src/cryptography/utils.py +++ b/src/cryptography/utils.py @@ -78,7 +78,7 @@ def verify_interface(iface, klass): 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 ) ) -- cgit v1.2.3 From c01a6c5856460c8172f166c8f4c94beaadc307f6 Mon Sep 17 00:00:00 2001 From: Alex Gaynor Date: Tue, 29 Sep 2015 21:31:00 -0400 Subject: flake8 --- src/cryptography/utils.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/cryptography/utils.py b/src/cryptography/utils.py index c91bcb2f..dac4046d 100644 --- a/src/cryptography/utils.py +++ b/src/cryptography/utils.py @@ -63,6 +63,7 @@ if hasattr(inspect, "signature"): else: signature = inspect.getargspec + def verify_interface(iface, klass): for method in iface.__abstractmethods__: if not hasattr(klass, method): -- cgit v1.2.3