Skip to content

Commit

Permalink
fix: TriG parser error handling for nested graphs (#2468)
Browse files Browse the repository at this point in the history
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 <[email protected]>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Iwan Aucamp <[email protected]>
  • Loading branch information
4 people committed Aug 16, 2023
1 parent 5c7643c commit f1e1316
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
3 changes: 3 additions & 0 deletions rdflib/plugins/parsers/trig.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,9 @@ def graph(self, argstr: str, i: int) -> int:

j = i + 1

if self._context is not None:
self.BadSyntax(argstr, i, "Nested graphs are not allowed")

oldParentContext = self._parentContext
self._parentContext = self._context
reason2 = self._reason2
Expand Down
3 changes: 0 additions & 3 deletions test/test_w3c_spec/test_trig_w3c.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,9 +176,6 @@ def check_entry(entry: ManifestEntry) -> None:
f"{REMOTE_BASE_IRI}#trig-graph-bad-01": pytest.mark.xfail(
reason="accepts GRAPH with no name"
),
f"{REMOTE_BASE_IRI}#trig-graph-bad-07": pytest.mark.xfail(
reason="accepts nested GRAPH"
),
}


Expand Down
2 changes: 1 addition & 1 deletion test_reports/rdflib_w3c_trig-HEAD.ttl
Original file line number Diff line number Diff line change
Expand Up @@ -971,7 +971,7 @@
earl:assertedBy <https://github.com/RDFLib/rdflib> ;
earl:mode earl:automatic ;
earl:result [ a earl:TestResult ;
earl:outcome earl:failed ] ;
earl:outcome earl:passed ] ;
earl:subject <https://github.com/RDFLib/rdflib> ;
earl:test <http://www.w3.org/2013/TriGTests/#trig-graph-bad-07> .

Expand Down

0 comments on commit f1e1316

Please sign in to comment.