[packagekit] Categories/Groups in yum on a Fedora system

S.Çağlar Onur caglar at pardus.org.tr
Thu Nov 1 01:19:39 PDT 2007


Hi;

31 Eki 2007 Çar tarihinde, S.Çağlar Onur şunları yazmıştı: 
> 31 Eki 2007 Çar tarihinde, Tim Lauridsen şunları yazmıştı:
> > I will add unicode convertion code.
>
> This breakes PiSi backend, not investigated what's wrong (and cannot for a
> while) but if needed here is the backtrace;

We found the problem, PiSi uses a special str class called LocalText which 
handles all these unicode conversions for us, it handles all fields 
translations and it also selects output language according to locale 
settings, like following;

In [17]: type(a.summary)
Out[17]: <class 'pisi.pxml.autoxml.LocalText'>

In [18]: a.summary["tr"]
Out[18]: 'GNU Bource again kabuğu'

In [19]: a.summary["en"]
Out[19]: 'The standard GNU Bourne again shell'

So isinstance(txt, types.UnicodeType) check fails and unicode( txt, 'utf-8' ) 
raises following;


In [25]: unicode( a.summary, 'utf-8' )
---------------------------------------------------------------------------
exceptions.TypeError
Traceback (most recent call last)

TypeError: coercing to Unicode: need string or buffer, LocalText found


So i propose following to handle this situation in backend.py if other 
backends also needs that _toUTF function or maybe this conversion can be 
handled in yum instead of backend.py.

Any comments?

diff --git a/python/packagekit/backend.py b/python/packagekit/backend.py
index 9c38a9e..720c332 100644
--- a/python/packagekit/backend.py
+++ b/python/packagekit/backend.py
@@ -268,6 +268,8 @@ class PackageKitBaseBackend:
                 rc = unicode( txt, 'utf-8' )
             except UnicodeDecodeError, e:
                 rc = unicode( txt, 'iso-8859-1' )
+            except TypeError:
+                return rc
             return rc
         
 #


Cheers
-- 
S.Çağlar Onur <caglar at pardus.org.tr>
http://cekirdek.pardus.org.tr/~caglar/

Linux is like living in a teepee. No Windows, no Gates and an Apache in house!
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.freedesktop.org/archives/packagekit/attachments/20071101/3878c940/attachment-0004.pgp>


More information about the PackageKit mailing list