Merge pull request #1186 from white-gecko/avoid_using_assert_in_sparq… · RDFLib/rdflib@dde9db8 (original) (raw)

Original file line number Diff line number Diff line change
@@ -52,8 +52,10 @@ def __init__(
52 52 self.kwargs = kwargs
53 53 self.method = method
54 54 if auth is not None:
55 -assert type(auth) == tuple, "auth must be a tuple"
56 -assert len(auth) == 2, "auth must be a tuple (user, password)"
55 +if type(auth) != tuple:
56 +raise SPARQLConnectorException("auth must be a tuple")
57 +if len(auth) != 2:
58 +raise SPARQLConnectorException("auth must be a tuple (user, password)")
57 59 base64string = base64.b64encode(bytes('%s:%s' % auth, 'ascii'))
58 60 self.kwargs.setdefault("headers", {})
59 61 self.kwargs["headers"].update({"Authorization": "Basic %s" % base64string.decode('utf-8')})