[GRASS-SVN] r68180 - grass/trunk/lib/python/script

svn_grass at osgeo.org svn_grass at osgeo.org
Mon Mar 28 23:29:14 PDT 2016


Author: zarch
Date: 2016-03-28 23:29:14 -0700 (Mon, 28 Mar 2016)
New Revision: 68180

Modified:
   grass/trunk/lib/python/script/utils.py
Log:
script.utils: fix bug in decode/encode function

Modified: grass/trunk/lib/python/script/utils.py
===================================================================
--- grass/trunk/lib/python/script/utils.py	2016-03-29 06:24:03 UTC (rev 68179)
+++ grass/trunk/lib/python/script/utils.py	2016-03-29 06:29:14 UTC (rev 68180)
@@ -156,10 +156,8 @@
     :param str string: the string to decode
     """
     enc = locale.getdefaultlocale()[1]
-    if enc:
-        if hasattr(string, 'decode'):
-            return string.decode(enc)
-
+    if hasattr(string, 'decode'):
+        return string.decode(enc) if enc else string.decode()
     return string
 
 
@@ -169,10 +167,8 @@
     :param str string: the string to encode
     """
     enc = locale.getdefaultlocale()[1]
-    if enc:
-        if hasattr(string, 'encode'):
-            return string.encode(enc)
-
+    if hasattr(string, 'encode'):
+        return string.encode(enc) if enc else string.encode()
     return string
 
 
@@ -376,5 +372,5 @@
             pathname = os.path.join(modulename, dirname) if dirname else modulename
             raise ImportError("Not able to find the path '%s' directory "
                               "(current dir '%s')." % (pathname, os.getcwd()))
-        
+
         sys.path.insert(0, path)



More information about the grass-commit mailing list