From 409a0c8d66a074033f7c6359c4f1578c9f479245 Mon Sep 17 00:00:00 2001 From: Paul Kehrer Date: Thu, 14 Sep 2017 11:15:58 +0800 Subject: implement __hash__ on DistributionPoint and CRLDistributionPoints (#3915) --- src/cryptography/x509/extensions.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'src/cryptography/x509/extensions.py') diff --git a/src/cryptography/x509/extensions.py b/src/cryptography/x509/extensions.py index 7a03139f..442000e3 100644 --- a/src/cryptography/x509/extensions.py +++ b/src/cryptography/x509/extensions.py @@ -412,6 +412,9 @@ class CRLDistributionPoints(object): def __getitem__(self, idx): return self._distribution_points[idx] + def __hash__(self): + return hash(tuple(self._distribution_points)) + class DistributionPoint(object): def __init__(self, full_name, relative_name, reasons, crl_issuer): @@ -487,6 +490,19 @@ class DistributionPoint(object): def __ne__(self, other): return not self == other + def __hash__(self): + if self.full_name is not None: + fn = tuple(self.full_name) + else: + fn = None + + if self.crl_issuer is not None: + crl_issuer = tuple(self.crl_issuer) + else: + crl_issuer = None + + return hash((fn, self.relative_name, self.reasons, crl_issuer)) + full_name = utils.read_only_property("_full_name") relative_name = utils.read_only_property("_relative_name") reasons = utils.read_only_property("_reasons") -- cgit v1.2.3