diff options
author | Paul Kehrer <paul.l.kehrer@gmail.com> | 2015-09-29 21:52:14 -0500 |
---|---|---|
committer | Paul Kehrer <paul.l.kehrer@gmail.com> | 2015-09-29 21:52:14 -0500 |
commit | 61b2f05da921891c588af45b6ab65abbdfe12f8f (patch) | |
tree | 416c5a2eab4acc285e6845905c80b9886c13b8ea | |
parent | a94f97ee8b32d35fc7ed02849a807fab58147dc5 (diff) | |
parent | c01a6c5856460c8172f166c8f4c94beaadc307f6 (diff) | |
download | cryptography-61b2f05da921891c588af45b6ab65abbdfe12f8f.tar.gz cryptography-61b2f05da921891c588af45b6ab65abbdfe12f8f.tar.bz2 cryptography-61b2f05da921891c588af45b6ab65abbdfe12f8f.zip |
Merge pull request #2385 from alex/use-signature
use signature so stuff works on 3.6 -- fixes #2382
-rw-r--r-- | src/cryptography/utils.py | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/src/cryptography/utils.py b/src/cryptography/utils.py index 237d5968..dac4046d 100644 --- 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 ) ) |