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

Adding should check the new triplet #227

Closed
jeroenh opened this issue Sep 6, 2012 · 2 comments
Closed

Adding should check the new triplet #227

jeroenh opened this issue Sep 6, 2012 · 2 comments

Comments

@jeroenh
Copy link
Contributor

jeroenh commented Sep 6, 2012

Consider the following:

>>> g = rdflib.Graph()
>>> g.add(("#foo","#bar","#foobar"))
>>> g.serialize()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/rdflib/graph.py", line 802, in serialize
    serializer.serialize(stream, base=base, encoding=encoding, **args)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/rdflib/plugins/serializers/rdfxml.py", line 62, in serialize
    bindings = list(self.__bindings())
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/rdflib/plugins/serializers/rdfxml.py", line 31, in __bindings
    prefix, namespace, name = nm.compute_qname(predicate)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/rdflib/namespace.py", line 264, in compute_qname
    namespace, name = split_uri(uri)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/rdflib/namespace.py", line 395, in split_uri
    if not category(c) in NAME_CATEGORIES:
TypeError: must be unicode, not str

The error is only caught when serializing the graph, not before. It seems to me that the .add() method should have caught this already.

@gromgull
Copy link
Member

gromgull commented Sep 7, 2012

This is the same as #200.

It's been open for long - but I wanted to do some performance checks before fixing - I'll have a look at your pull req, thanks!

@gromgull gromgull closed this as completed Sep 7, 2012
@jeroenh
Copy link
Contributor Author

jeroenh commented Sep 7, 2012

I heard that performance might be an issue, which is why I used assert statements. Those will get removed if you're asking Python to do performance enhancements.
On the one hand this means that it's not a fool-proof fix, but it does make it a lot more userfriendly for 90% of the users. And the other 10% should run their code in normal mode first anyway ;).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants