summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicholas Car <nicholas.car@surroundaustralia.com>2020-10-09 00:40:56 +1000
committerGitHub <noreply@github.com>2020-10-09 00:40:56 +1000
commitdde9db804d30fe0ab0c3291c105093ed691b0ef4 (patch)
tree2a01deb5326e7d074484a83618f32d392b835fe7
parent7a53c615c528d0fc0af55fa6a5b925c330cb5239 (diff)
parentb42e5a5cfa4ac535f259146043de15f701a671a2 (diff)
downloadrdflib-dde9db804d30fe0ab0c3291c105093ed691b0ef4.tar.gz
Merge pull request #1186 from white-gecko/avoid_using_assert_in_sparqlconnector
Remove the usage of assert in the SPARQLConnector
-rw-r--r--rdflib/plugins/stores/sparqlconnector.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/rdflib/plugins/stores/sparqlconnector.py b/rdflib/plugins/stores/sparqlconnector.py
index cda79d7e..13571caa 100644
--- a/rdflib/plugins/stores/sparqlconnector.py
+++ b/rdflib/plugins/stores/sparqlconnector.py
@@ -52,8 +52,10 @@ class SPARQLConnector(object):
self.kwargs = kwargs
self.method = method
if auth is not None:
- assert type(auth) == tuple, "auth must be a tuple"
- assert len(auth) == 2, "auth must be a tuple (user, password)"
+ if type(auth) != tuple:
+ raise SPARQLConnectorException("auth must be a tuple")
+ if len(auth) != 2:
+ raise SPARQLConnectorException("auth must be a tuple (user, password)")
base64string = base64.b64encode(bytes('%s:%s' % auth, 'ascii'))
self.kwargs.setdefault("headers", {})
self.kwargs["headers"].update({"Authorization": "Basic %s" % base64string.decode('utf-8')})