Check triple arguments in graph

diff -r fcdc45fdd8ba rdflib/Graph.py
--- a/rdflib/Graph.py	Wed Jul 04 09:43:53 2007 +0200
+++ b/rdflib/Graph.py	Wed Jul 04 09:45:32 2007 +0200
@@ -269,6 +269,10 @@ class Graph(Node):
         self.context_aware = False
         self.formula_aware = False
 
+    def __eq__(self, rhs):
+        if not isinstance(rhs, self.__class__): return False
+        return list(self.triples((None, None, None))) == list(rhs.triples((None, None, None)))
+
     def __get_store(self):
         return self.__store
     store = property(__get_store)
@@ -326,6 +330,7 @@ class Graph(Node):
 
     def add(self, (s, p, o)):
         """Add a triple with self as context"""
+        self._check_triple(s, p, o)
         self.__store.add((s, p, o), self, quoted=False)
 
     def addN(self, quads):
@@ -745,6 +750,14 @@ class Graph(Node):
         allNodes = obj.union(set(self.subjects()))
         return allNodes
 
+    def _check_triple(self, s, p, o):
+        if s is None:
+            raise ValueError, "Invalid value for subject: %s" % s
+        if p is None:
+            raise ValueError, "Invalid value for predicate: %s" % p
+        if o is None:
+            raise ValueError, "Invalid value for object: %s" % o
+        
 
 class ConjunctiveGraph(Graph):
 
@@ -763,10 +776,13 @@ class ConjunctiveGraph(Graph):
 
     def add(self, (s, p, o)):
         """Add the triple to the default context"""
+        self._check_triple(s, p, o)
         self.store.add((s, p, o), context=self.default_context, quoted=False)
 
     def addN(self, quads):
         """Add a sequence of triple with context"""
+        for s, p, o in [(s, p, o, c) in quads]:
+            self._check_triple(s, p, o)
         self.store.addN(quads)
 
     def remove(self, (s, p, o)):
