Mailinglist Archive: opensuse-buildservice (312 mails)

< Previous Next >
Re: [opensuse-buildservice] osc umlaut problem
  • From: Marcus Hüwe <suse-tux@xxxxxx>
  • Date: Thu, 2 Jul 2009 17:57:03 +0200
  • Message-id: <20090702155703.GA3504@xxxxxxxxxxxxxxxxxxxxxx>
On 2009-07-02 08:19:18 +0200, Michal Čihař wrote:
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

That's due to the implementation of the print function. It implicitly calls
str() on the string returned by __str__() which fails in case the string is a
unicode object which contains chars which cannot be converted to ascii (in
this case 0xfc). It seems that if you directly pass a string or unicode object
to the print call no str() method is called.
Another question is if the usage of __str__() is correct in this case because
we obviously can't ensure that the result can be converted to ascii - so should
we use __unicode__() instead of __str__() in this case?

To unsubscribe, e-mail: opensuse-buildservice+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: opensuse-buildservice+help@xxxxxxxxxxxx

< Previous Next >
List Navigation