diff options
author | Joern Hees <dev@joernhees.de> | 2015-03-04 13:55:19 +0100 |
---|---|---|
committer | Joern Hees <dev@joernhees.de> | 2015-03-04 13:55:19 +0100 |
commit | c2dd5fb7ac40ef143da636ba15648dbff3bc981d (patch) | |
tree | f4023f831de01844af3251f018fa0ebcaafd488e | |
parent | e80c6186fee68219e19bc2adae2cd5edf20bfef9 (diff) | |
download | rdflib-c2dd5fb7ac40ef143da636ba15648dbff3bc981d.tar.gz |
added asserts for graph.set([s,p,o]) so s and p aren't None
otherwise this will delete (*, p, *) or (s, *, *) or even (*, *, *) from graph
and fails on add which is most likely not what the developer wants.
-rw-r--r-- | rdflib/graph.py | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/rdflib/graph.py b/rdflib/graph.py index dbbe67c8..68339eba 100644 --- a/rdflib/graph.py +++ b/rdflib/graph.py @@ -611,9 +611,13 @@ class Graph(Node): Remove any existing triples for subject and predicate before adding (subject, predicate, object). """ - (subject, predicate, object) = triple + (subject, predicate, object_) = triple + assert subject is not None, \ + "s can't be None in .set([s,p,o]), as it would remove (*, p, *)" + assert predicate is not None, \ + "p can't be None in .set([s,p,o]), as it would remove (s, *, *)" self.remove((subject, predicate, None)) - self.add((subject, predicate, object)) + self.add((subject, predicate, object_)) def subjects(self, predicate=None, object=None): """A generator of subjects with the given predicate and object""" |