Bug#574637: python-cupsutils: Problem parsing PPD attributes : UnicodeDecodeError: 'utf8' codec can't decode

Olivier Berger olivier.berger at it-sudparis.eu
Fri Mar 19 16:23:12 UTC 2010


tags 574637 + patch
forwarded 574637 https://bugs.launchpad.net/ubuntu/+source/system-config-printer/+bug/299074
thanks

On Fri, Mar 19, 2010 at 04:41:08PM +0100, Olivier Berger wrote:
> 
> Hi.
> 
> I've tried and configure a Canon imagerunner 3225 printer using system-config-printer, and get the following traces :
> 
> raceback (most recent call last):
>   File "/usr/bin/system-config-printer", line 4317, in on_tvNPModels_cursor_changed
>     self.fillDriverList(self.NPMake, pmodel)
>   File "/usr/bin/system-config-printer", line 4280, in fillDriverList
>     self.NPDrivers = self.ppds.orderPPDNamesByPreference(ppds.keys()) 
>   File "/usr/lib/pymodules/python2.5/cupsutils/ppds.py", line 378, in orderPPDNamesByPreference
>     ppdnamelist.sort (sort_ppdnames)
>   File "/usr/lib/pymodules/python2.5/cupsutils/ppds.py", line 356, in sort_ppdnames
>     ca = is_C_locale (a)
>   File "/usr/lib/pymodules/python2.5/cupsutils/ppds.py", line 342, in is_C_locale
>     elif x[i - 1] not in string.letters:
> UnicodeDecodeError: 'utf8' codec can't decode byte 0xaa in position 52: unexpected code byte
> 
> 

It seems this can be solved by simply applying the following patch (available in upstream most recent version) :

--- /usr/share/pyshared/cupsutils/ppds.py~	2009-06-17 10:52:03.000000000 +0200
+++ /usr/share/pyshared/cupsutils/ppds.py	2010-03-19 17:19:06.000000000 +0100
@@ -332,7 +332,8 @@
             # Prefer C locale localized PPDs to other languages,
             # just because we don't know the user's locale.
             def is_C_locale (x):
-                while x:
+              try:
+                  while x:
                     i = x.find ("C")
                     if i == -1:
                         return False
@@ -352,6 +353,8 @@
                             return True
                         
                     x = x[i + 1:]
+              except UnicodeDecodeError:
+                    return False
 
             ca = is_C_locale (a)
             cb = is_C_locale (b)

Thanks for updating the package or applying this patch.

FYI, there's a similar upstream bug, I think  : https://bugs.launchpad.net/ubuntu/+source/system-config-printer/+bug/299074

Best regards,






More information about the pkg-gnome-maintainers mailing list