Mailinglist Archive: opensuse-buildservice (312 mails)

< Previous Next >
Re: [opensuse-buildservice] osc umlaut problem
  • From: Susanne Oberhauser <froh@xxxxxxxxxx>
  • Date: Fri, 03 Jul 2009 10:09:06 +0200
  • Message-id: <s2ifxde6vdp.fsf@xxxxxxxxxxxxx>
Michal Čihař <michal@xxxxxxxxx> writes:

Hi

Dne Thu, 02 Jul 2009 07:28:58 +0200
Susanne Oberhauser <froh@xxxxxxxxxx> napsal(a):

can you guys reproduce the problem with this command line?

osc request show 12780

Yes.

I'm on openSUSE 11.1 with obs 0.120 from openSUSE:Tools.

On both openSUSE 11.1 and Debian unstable, osc 0.120.

What I don't get is why "print s" from the debugger does it right,
while the print in osc fails in my debugging session.

Just played a bit with the source and I have to admit that I do not
understand how the string conversion works :-).

These work fine:

print r.__str__()
print unicode(r)

But this one does not:

print r

Researching a bit on python and unicode, I think the culprit is how we
initialize the default encoding.

Looking at /usr/lib/python2.6/site.py, we don't use the locale settings
(LANG, LC_*) but hard code ascii.

As a result of this, str() tries to encode the result of __str__ to
ascii, which fails.


The sys.setdefaultencoding function is disabled after site
initialization on purpose: http://www.python.org/dev/peps/pep-0100/

The purpose isn't clear, though.

There is thre fixes to this:

1. we enable in syte.py the use of the locale setting

2. we work around the IMNSHO braindead disablement of
"setdefaultencoding":

import sys, locale
reload(sys)
sys.setdefaultencoding(locale.getdefaultlocale()[1])

3. We scatter explicit unicode awareness to every place we possibly
handle unicode strings strings.


I *strongly* opt for #1 or #2. #3 is just so plain inelegant, I refuse
to do that. It's like checking return codes after exceptions have been
invented.


S.

--
Susanne Oberhauser +49-911-74053-574 SUSE -- a Novell Business
OPS Engineering Maxfeldstraße 5
Processes and Infrastructure Nürnberg
SUSE LINUX Products GmbH, GF: Markus Rex, HRB 16746 (AG Nürnberg)
--
To unsubscribe, e-mail: opensuse-buildservice+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: opensuse-buildservice+help@xxxxxxxxxxxx

< Previous Next >
List Navigation
Follow Ups