[jhbuild] Decode lsb_release output using preferred encoding



commit b820daf5dcadc826d489cdcd060fc7f69917910c
Author: Jiro Matsuzawa <jmatsuzawa gnome org>
Date:   Thu Aug 1 16:50:44 2013 +0900

    Decode lsb_release output using preferred encoding
    
    lsb_release may output non-ascii characters. For example, it prints
    "Schrödinger’sCat" for the codename of Fedora 19. It caused jhbuild to
    crash with UnicodeDecodeError in writing a tinderbox log.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=699434

 jhbuild/frontends/tinderbox.py |    9 ++++++---
 1 files changed, 6 insertions(+), 3 deletions(-)
---
diff --git a/jhbuild/frontends/tinderbox.py b/jhbuild/frontends/tinderbox.py
index eb85d27..c99eedc 100644
--- a/jhbuild/frontends/tinderbox.py
+++ b/jhbuild/frontends/tinderbox.py
@@ -136,9 +136,12 @@ buildlog_footer = '''
 def get_distro():
     # try using the lsb_release tool to get the distro info
     try:
-        distro = cmds.get_output(['lsb_release', '--short', '--id']).strip()
-        release = cmds.get_output(['lsb_release', '--short', '--release']).strip()
-        codename = cmds.get_output(['lsb_release', '--short', '--codename']).strip()
+        distro = cmds.get_output(['lsb_release', '--short', '--id']) \
+                     .decode(_encoding).strip()
+        release = cmds.get_output(['lsb_release', '--short', '--release']) \
+                      .decode(_encoding).strip()
+        codename = cmds.get_output(['lsb_release', '--short', '--codename']) \
+                       .decode(_encoding).strip()
         if codename:
             return '%s %s (%s)' % (distro, release, codename)
         else:


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