Ah, that's interesting.
Given that URIRef is a subclass of unicode, I would suggest changing the line `isinstance(literal, basestring):` to `isinstance(literal, str):`.

The intention of that line is to normalise all str to unicode representation anyway.