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

Bug#750120: python-apt: Some locales use no-breaking space for LC_NUMBER, so return unicode for SizeToStr



On Fri, Jun 06, 2014 at 09:03:11AM +0200, Michael Vogt wrote:
> On Sun, Jun 01, 2014 at 09:18:45PM +0200, Odin Hørthe Omdal wrote:
> > Package: python-apt
> > Version: 0.9.3.5
> > Severity: normal
> > Tags: upstream l10n patch
> 
> Thanks for your bugreport and your patch!
>  
> > this is on Ubuntu, but this was the closest I could find to the python-apt
> > upstream :)
> > 
> > This is breaking the distribution upgrade on my girlfriends computer
> > (since she is using nn_NO.UTF8 as her language).
> > 
> > Ubuntu's upgrading python script is not expecting that the str returned
> > will have undecodeable chars. This could also be fixed at Ubuntu's
> > level, but looking at it, I thought it hit closer to home for
> > apt_pkg.size_to_str() to return a ready decoded unicode string to all
> > its users.
> [..]
> 
> Indeed, thanks for this fix! Unfortunately as it is right now it
> breaks the API of size_to_str(), i.e. there are probably apps who
> expect a type "str". So we either need to add a size_to_unicode() or a
> kwarg like "as_unicode" or add a warning in the documentation for the
> py2 users.

We should just leave it as it is. Python 3 is unicode. Python 2 has been
str all the time, there's no point changing this and breaking things or
introducing new APIs that are (a) pointless (b) for a deprecated language.

I do not believe that returning str causes a problem itself. There may
be some applications that have problems with it. Printing it to a console
or a file or displaying it in a window works just fine because there
*cannot* be any decoding/encoding problems, since all is bytes. Unless
of course, the applications tries to print to an encoded stream, but
this means the app uses io.open() which is a minority that should deal
itself with the problems this causes.

I believe it's more likely that the distribution upgrade script is
using an io.open() file instead and has a problem encoding things
here. This can be fixed easily be changing it to use an unencoded
bytes stream.
-- 
Julian Andres Klode  - Debian Developer, Ubuntu Member

See http://wiki.debian.org/JulianAndresKlode and http://jak-linux.org/.

Please do not top-post if possible.


Reply to: