[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] Gettexted messages encoding with Python 2.5

From: John Mandereau
Subject: Re: [PATCH] Gettexted messages encoding with Python 2.5
Date: Wed, 04 Jul 2007 16:03:17 +0200

Le lundi 02 juillet 2007 à 21:58 -0300, Han-Wen Nienhuys a écrit :
> 2007/7/2, John Mandereau <address@hidden>:
> > To fix this, we must use ugettext instead of gettext in
> > Unfortunately, this fix implies that each gettexted string must be
> > converted from Python internal Unicode to stdout/stderr encoding before
> > being written to stdout/stderr.
> >
> > May I commit and push the following patch, that intends to solve all
> > problems above?
> I'm not aware of all the issues, but I believe your story. However,
> would it be better to define a encoded_write or similar, ie.
>   def encoded_write(f, s):
>     f.write (s.encode (f.encoding))
> and perhaps
>   def log(s):
>     encoded_write(sys.stderr, s)

You're right, it avoids code duplication.

There is something I don't catch in this story: print does the
encoded_write conversion defnined above automatically.  Why would we
have to add a layer to the file.write method, whereas file.write could
do the conversion itself, since it can read the file.encoding property?
I feel a bit like this is a bug/limitation in Python 2.5 file.write()

As I have no urgent need using lilypond-book from Git HEAD (I only
wanted to see 'lilypond-book --help' output when looking at updating
lilypond-book docs), I'll submit a patch/report the bug to Python
hackers when I'm back.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]