diff options
author | Paul Kehrer <paul.l.kehrer@gmail.com> | 2015-10-24 19:02:08 -0500 |
---|---|---|
committer | Paul Kehrer <paul.l.kehrer@gmail.com> | 2015-10-24 19:02:08 -0500 |
commit | b7ee910c2070a3e5d8d64ac17ceaa5793f114dc1 (patch) | |
tree | effdff93a30a4420b105030b30d7beb4e31067d9 /src | |
parent | 95080e9fdac5865dfc5977051c20c6ef1aec0f17 (diff) | |
parent | 1aecec7012b554fef96a543e1c0581e00de53583 (diff) | |
download | cryptography-b7ee910c2070a3e5d8d64ac17ceaa5793f114dc1.tar.gz cryptography-b7ee910c2070a3e5d8d64ac17ceaa5793f114dc1.tar.bz2 cryptography-b7ee910c2070a3e5d8d64ac17ceaa5793f114dc1.zip |
Merge pull request #2445 from alex/name-hash
Fixed #2444 -- added an __hash__ to x509 Names
Diffstat (limited to 'src')
-rw-r--r-- | src/cryptography/x509/name.py | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/cryptography/x509/name.py b/src/cryptography/x509/name.py index 992786ef..9d93ece1 100644 --- a/src/cryptography/x509/name.py +++ b/src/cryptography/x509/name.py @@ -40,6 +40,9 @@ class NameAttribute(object): def __ne__(self, other): return not self == other + def __hash__(self): + return hash((self.oid, self.value)) + def __repr__(self): return "<NameAttribute(oid={0.oid}, value={0.value!r})>".format(self) @@ -60,6 +63,11 @@ class Name(object): def __ne__(self, other): return not self == other + def __hash__(self): + # TODO: this is relatively expensive, if this looks like a bottleneck + # for you, consider optimizing! + return hash(tuple(self._attributes)) + def __iter__(self): return iter(self._attributes) |