fix: TriG handling of GRAPH keyword without a graph ID (#2469) · RDFLib/rdflib@8c9608b (original) (raw)

Original file line number Diff line number Diff line change
@@ -69,16 +69,20 @@ def graph(self, argstr: str, i: int) -> int:
69 69 raise Exception if it looks like a graph, but isn't.
70 70 """
71 71
72 +need_graphid = False
72 73 # import pdb; pdb.set_trace()
73 74 j = self.sparqlTok("GRAPH", argstr, i) # optional GRAPH keyword
74 75 if j >= 0:
75 76 i = j
77 +need_graphid = True
76 78
77 79 r: MutableSequence[Any] = []
78 80 j = self.labelOrSubject(argstr, i, r)
79 81 if j >= 0:
80 82 graph = r[0]
81 83 i = j
84 +elif need_graphid:
85 +self.BadSyntax(argstr, i, "GRAPH keyword must be followed by graph name")
82 86 else:
83 87 graph = self._store.graph.identifier # hack
84 88