Skip to content

Fix incorrect deskolemization of literals #3127

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions rdflib/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -1927,10 +1927,11 @@ def do_de_skolemize2(t: _TripleType) -> _TripleType:
elif Genid._is_external_skolem(s):
s = Genid(s).de_skolemize()

if RDFLibGenid._is_rdflib_skolem(o):
o = RDFLibGenid(o).de_skolemize()
elif Genid._is_external_skolem(o):
o = Genid(o).de_skolemize()
if isinstance(o, URIRef):
if RDFLibGenid._is_rdflib_skolem(o):
o = RDFLibGenid(o).de_skolemize()
elif Genid._is_external_skolem(o):
o = Genid(o).de_skolemize()

return s, p, o

Expand Down
20 changes: 20 additions & 0 deletions test/test_issues/test_issue3126.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@

import pytest

from rdflib import Graph


def test_skolem_de_skolem_roundtrip():
"""Test deskolemization should ignore literals.

Issue: https://github.com/RDFLib/rdflib/issues/3126
"""

nt = '<http://example.com> <http://example.com> "http://example.com [some remark]" .'

graph = Graph().parse(data=nt, format="nt").de_skolemize()

try:
graph.de_skolemize()
except BaseException as ex:
pytest.fail(f'Unexpected error: {ex}')