Skip to content

Commit f1e1316

Browse files
WhiteGobopre-commit-ci[bot]aucampia
committed
fix: TriG parser error handling for nested graphs (#2468)
Raise an error when nested graphs occur in TriG. With this change, the <http://www.w3.org/2013/TriGTests/#trig-graph-bad-07> test passes. --------- Co-authored-by: WhiteGobo <richardfechner@posteo.net> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Iwan Aucamp <aucampia@gmail.com>
1 parent 5c7643c commit f1e1316

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

rdflib/plugins/parsers/trig.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,9 @@ def graph(self, argstr: str, i: int) -> int:
9898

9999
j = i + 1
100100

101+
if self._context is not None:
102+
self.BadSyntax(argstr, i, "Nested graphs are not allowed")
103+
101104
oldParentContext = self._parentContext
102105
self._parentContext = self._context
103106
reason2 = self._reason2

test/test_w3c_spec/test_trig_w3c.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -176,9 +176,6 @@ def check_entry(entry: ManifestEntry) -> None:
176176
f"{REMOTE_BASE_IRI}#trig-graph-bad-01": pytest.mark.xfail(
177177
reason="accepts GRAPH with no name"
178178
),
179-
f"{REMOTE_BASE_IRI}#trig-graph-bad-07": pytest.mark.xfail(
180-
reason="accepts nested GRAPH"
181-
),
182179
}
183180

184181

test_reports/rdflib_w3c_trig-HEAD.ttl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -971,7 +971,7 @@
971971
earl:assertedBy <https://github.com/RDFLib/rdflib> ;
972972
earl:mode earl:automatic ;
973973
earl:result [ a earl:TestResult ;
974-
earl:outcome earl:failed ] ;
974+
earl:outcome earl:passed ] ;
975975
earl:subject <https://github.com/RDFLib/rdflib> ;
976976
earl:test <http://www.w3.org/2013/TriGTests/#trig-graph-bad-07> .
977977

0 commit comments

Comments
 (0)