RDFLib/rdflib — Issue #141: problem with unicode literals in rdflib.compare.graph_diff
Author: gjhiggins
Created: 2012-02-20 08:33:40+00:00
State: open

pierre.a...@gmail.com, 2010-11-16T16:55:02.000Z

What steps will reproduce the problem?

from rdflib import Graph
from rdflib.compare import graph_diff
g1 = Graph()
g1.load("http://champin.net/foaf.rdf")
diff = graph_diff(g1, g1)

raises:
UnicodeEncodeError: 'ascii' codec can't encode character u'\xe9' in position 0: ordinal not in range(128)

What is the expected output? What do you see instead?

should not raise an exception...

What version of the product are you using? On what operating system?

rdflib 3.0.0 on Linux, python 2.6.6

Please provide any additional information below.

line 219 of rdflib/compare.py should be
h.update(unicode(i).encode("utf8"))
this fixes the problem.

On the other hand, the fix above works with python 2.x, but would probably not work in python 3.x, while the original code probably works.

I don't know what is the best way to make the code compliant with both python 2 and 3, nor if this is relevant for rdflib.

Comment 1 by gromgull
fixed in r1905