Skip to content
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

Serializing turtle file with python3 causes TypeError: unorderable types: DocumentFragment() > DocumentFragment() #676

Closed
olberger opened this issue Dec 22, 2016 · 2 comments
Labels
bug Something isn't working
Milestone

Comments

@olberger
Copy link

trying to parse the following Turtle file
test.txt with:

from rdflib import Graph

g = Graph()
g.parse("test.ttl", format="turtle")

s = g.serialize(format='turtle')
print(s)

crashes with somethong like:

Traceback (most recent call last):
  File "serialize.py", line 7, in <module>
    s = g.serialize(format='turtle')
  File "/home/olivier/git/github.com/RDFLib/rdflib/build/py3_testing/rdflib/graph.py", line 942, in serialize
    serializer.serialize(stream, base=base, encoding=encoding, **args)
  File "/home/olivier/git/github.com/RDFLib/rdflib/build/py3_testing/rdflib/plugins/serializers/turtle.py", line 209, in serialize
    if self.statement(subject) and not firstTime:
  File "/home/olivier/git/github.com/RDFLib/rdflib/build/py3_testing/rdflib/plugins/serializers/turtle.py", line 270, in statement
    return self.s_squared(subject) or self.s_default(subject)
  File "/home/olivier/git/github.com/RDFLib/rdflib/build/py3_testing/rdflib/plugins/serializers/turtle.py", line 275, in s_default
    self.predicateList(subject)
  File "/home/olivier/git/github.com/RDFLib/rdflib/build/py3_testing/rdflib/plugins/serializers/turtle.py", line 370, in predicateList
    propList = self.sortProperties(properties)
  File "/home/olivier/git/github.com/RDFLib/rdflib/build/py3_testing/rdflib/plugins/serializers/turtle.py", line 107, in sortProperties
    objects.sort()
  File "/home/olivier/git/github.com/RDFLib/rdflib/build/py3_testing/rdflib/term.py", line 823, in __gt__
    return self.value > other.value
TypeError: unorderable types: DocumentFragment() > DocumentFragment()

It's specific to Python3 though. 2.7 will be fine.

@gromgull gromgull added this to the rdflib 4.2.2 milestone Jan 12, 2017
@gromgull gromgull added the bug Something isn't working label Jan 12, 2017
@gromgull
Copy link
Member

related: #613

gromgull added a commit that referenced this issue Jan 19, 2017
Made turtle serialiser use a comparator function falling back on
string-comparisons.

fixes #648, #613, #676
@gromgull
Copy link
Member

fixed in 13ce988

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants