[redland-dev] unicode issue on os x with python bindings

Suzan Foster su at islief.nl
Wed May 11 21:43:11 BST 2005


On May 11, 2005, at 10:31 PM, Christopher Schmidt wrote:

> On Wed, May 11, 2005 at 10:19:58PM +0200, Suzan Foster wrote:
>> I'm hitting an error on my mac with a python script which I'm not
>> seeing when running with windows. It's also my first attempt at 
>> python,
>> which doesn't help :-| Anybody who can steer me in the right 
>> direction?
>>
>> http://www.ipodder.org/aboutTheDirectory threw an exception.
>>   librdf_new_uri() argument 2 must be string without null bytes, not 
>> str
>
> Not sure exactly what "http://www.ipodder.org/aboutTheDirectory" is
> supposed to be: if you could give a copy of the code snippet which is
> causing the proglem, it might help me.

Basically it's the RDF.Uri constructor that's failing. This is the 
version with the use of str() as you suggested. This however throws the 
same error. The full script was attached to my original post.

         def process_channel(self, uri):
                 print "Found channel", uri
                 try:
                         statement = RDF.Statement(RDF.Uri(str(uri)), 
self.rdftype, self.channel)
                         if self.model.contains_statement(statement) : 
return
                         model = RDF.Model(self.storage)
                         parser = RDF.Parser(name="rss-tag-soup")
                         parser.parse_into_model(model, uri);
                         if model.contains(statement):
                                 self.model.add_statement(statement)
                                 print "Added", uri
                 except Exception, e:
                         print uri, "threw an exception.", e

>
> However, when I've run into this issue in the past, it has been as a
> result of trying to pass in a <type 'unicode'> string rather than a
> <type 'string'> string. You may want to check your code and run a str()
> around anything that might be of type "unicode": you can test this by
> using the function type(variable), and you can cast it by using
> str(variable).

It was indeed of type unicode, however casting didn't solve the problem.

Regards,
Suzan Foster.



More information about the redland-dev mailing list