On Feb  2, 2011   8:28:24PM +0100, Olav Vitters wrote:
> On Wed, Feb 02, 2011 at 07:11:08PM +0100, Tobias Mueller wrote:
> > Heya,
> > 
> > I haven't had a look at the scripts, but maybe I can still contribute
> > something.
> > 
> > On 02.02.2011 15:29, Olav Vitters wrote:
> > > Problem is the handling of encoded data.
> > When you read() the data, immediately decode() it with the proper
> > encoding so that the data will become a Unicode object, i.e.
> > fileobject.read().decode('utf-8').
> 
> The UTF-8 is coming from http://git.gnome.org/repositories.doap (Máirín
> Duffy). I'm not sure if Python sees that as UTF-8 or not. And perhaps
> there is a mix of UTF-8 and non-UTF-8. How could I check the variables
> what encoding Python thinks it is in? type(variable)?
> 
> At least I figured out how to reproduce the error on the server...
> 
> # /home/admin/bin/handle-ldap-modules sync
> works
> 
> # /home/admin/bin/handle-ldap-modules sync | cat
> UnicodeEncodeError: 'ascii' codec can't encode character u'\xe1' in position 
> 1573: ordinal not in range(128)
> 
> (same error as forwarded)
> 
> -- 
> Regards,
> Olav

If my understanding is correct, Python has an internal string
representation which you can reveal:
        a = 'hi'
        b = unicode(a)
        print type(a)
        print type(b)
but which you aren't really concerned with. To handle input, just use
the decode() function and to handle output, use encode().

I think that the problem is not within python but with the environment.
What's the output of "locale" as your user and as the user owning the
crontab?

Attachment: signature.asc
Description: Digital signature

_______________________________________________
gnome-infrastructure mailing list
[email protected]
http://mail.gnome.org/mailman/listinfo/gnome-infrastructure

Reply via email to