aboutsummaryrefslogtreecommitdiffstats
path: root/src/cryptography/x509/name.py
diff options
context:
space:
mode:
authorAlex Gaynor <alex.gaynor@gmail.com>2015-10-24 18:32:10 -0400
committerAlex Gaynor <alex.gaynor@gmail.com>2015-10-24 18:32:10 -0400
commit9442fa9afab67146c02a994463186b7c09908f77 (patch)
tree5d5422fa7c83d2d897fa630286c4048be8cb82cf /src/cryptography/x509/name.py
parent95080e9fdac5865dfc5977051c20c6ef1aec0f17 (diff)
downloadcryptography-9442fa9afab67146c02a994463186b7c09908f77.tar.gz
cryptography-9442fa9afab67146c02a994463186b7c09908f77.tar.bz2
cryptography-9442fa9afab67146c02a994463186b7c09908f77.zip
Fixed #2444 -- added an __hash__ to x509 Names
Diffstat (limited to 'src/cryptography/x509/name.py')
-rw-r--r--src/cryptography/x509/name.py8
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)