walidazizi / rdflib

Automatically exported from code.google.com/p/rdflib
Other
0 stars 0 forks source link

Literal.__str__ does not behave like unicode #128

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Literal is a subclass of unicode.
However, its __str__ method has not the same semantics as unicode's,
because it uses the "unicode-escape" codec instead of the default system 
codec.

>>> from rdflib import Literal
>>> str(unicode('a\n'))
'a\n'
>>> str(Literal('a\n'))
'a\\n'
>>> str(unicode(Literal('a\n')))
'a\n'

This might be a feature, but breaks expectations: I tend to use Literals as 
any other unicode strings (slicing, startswith, etc...), so having to 
manage them specially only for str conversion seems a misfeature.

Original issue reported on code.google.com by pierre.a...@gmail.com on 18 May 2010 at 1:29

GoogleCodeExporter commented 8 years ago
Pierre, thank you for reporting this issue.

I know there are some unresolvable issues that arise from the choice of having 
Literal subclass unicode. I'm not 
sure if this is one of the unresolvable ones or not. We should take a look to 
see if we can fix this issue without 
breaking other bits. I'll work on a patch now to see what all fixing this will 
entail.

Original comment by eike...@gmail.com on 21 May 2010 at 2:34

GoogleCodeExporter commented 8 years ago
This issue was closed by revision r1876.

Original comment by eik...@gmail.com on 21 May 2010 at 2:49

GoogleCodeExporter commented 8 years ago
Unless this breaks bits for which we do not yet have a test case. We are good 
to go; the fix was fairly straight 
forward. If there are broken bits as a result of this change we'll need a test 
case for it.

Original comment by eike...@gmail.com on 21 May 2010 at 2:51

GoogleCodeExporter commented 8 years ago
This issue was closed by revision a37a1cf8a191.

Original comment by eik...@gmail.com on 30 Mar 2011 at 9:07