From c2dd5fb7ac40ef143da636ba15648dbff3bc981d Mon Sep 17 00:00:00 2001 From: Joern Hees Date: Wed, 4 Mar 2015 13:55:19 +0100 Subject: 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. --- rdflib/graph.py | 8 ++++++-- 1 file 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""" -- cgit v1.2.1