Skip to content

Commit eb4100e

Browse files
committed
first deletion of assertion
1 parent 1aeae3a commit eb4100e

File tree

3 files changed

+9
-7
lines changed

3 files changed

+9
-7
lines changed

src/saml2/__init__.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -822,9 +822,7 @@ def clear_text(self):
822822
self.text = None
823823

824824
def __eq__(self, other):
825-
try:
826-
assert isinstance(other, SamlBase)
827-
except AssertionError:
825+
if not isinstance(other, SamlBase):
828826
return False
829827

830828
self.clear_text()

src/saml2/sigver.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,8 @@ def split_len(seq, length):
356356

357357

358358
def to_time(_time):
359-
assert _time.endswith(' GMT')
359+
if not _time.endswith(' GMT'):
360+
raise Exception('Time does not end with GMT')
360361
_time = _time[:-4]
361362
return mktime(str_to_time(_time, M2_TIME_FORMAT))
362363

@@ -372,8 +373,10 @@ def active_cert(key):
372373
try:
373374
cert_str = pem_format(key)
374375
cert = crypto.load_certificate(crypto.FILETYPE_PEM, cert_str)
375-
assert cert.has_expired() == 0
376-
assert not OpenSSLWrapper().certificate_not_valid_yet(cert)
376+
if not cert.has_expired() == 0:
377+
raise Exception('Cert is expired.')
378+
if OpenSSLWrapper().certificate_not_valid_yet(cert):
379+
raise Exception('Certificate not valid yet.')
377380
return True
378381
except AssertionError:
379382
return False

src/saml2/time_util.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,8 @@ def parse_duration(duration):
6767
index += 1
6868
else:
6969
sign = '+'
70-
assert duration[index] == "P"
70+
if duration[index] != "P":
71+
raise Exception('Parse Duration is not valid.')
7172
index += 1
7273

7374
dic = dict([(typ, 0) for (code, typ) in D_FORMAT if typ])

0 commit comments

Comments
 (0)