]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/blobdiff - src/allmydata/util/stringutils.py
Fix for Unicode-related test failures on Zooko's OS X 10.6 machine.
[tahoe-lafs/tahoe-lafs.git] / src / allmydata / util / stringutils.py
index bce2868d0af18681e6772077bdb71a4d42508a3a..99c0d8c5ee142c23054e36668afb401a45327964 100644 (file)
@@ -115,7 +115,7 @@ def unicode_to_output(s):
 
     try:
         out = s.encode(output_encoding)
-    except UnicodeEncodeError:
+    except (UnicodeEncodeError, UnicodeDecodeError):
         raise UnicodeEncodeError(output_encoding, s, 0, 0,
                                  "A string could not be encoded as %s for output to the terminal:\n%r" %
                                  (output_encoding, repr(s)))
@@ -143,7 +143,7 @@ def quote_output(s, quotemarks=True):
 
     try:
         out = s.encode(output_encoding)
-    except UnicodeEncodeError:
+    except (UnicodeEncodeError, UnicodeDecodeError):
         return repr(s)
 
     if PRINTABLE_8BIT.search(out) is None:
@@ -182,7 +182,7 @@ def listdir_unicode_fallback(path):
 
     try:
         byte_path = path.encode(filesystem_encoding)
-    except UnicodeEncodeError:
+    except (UnicodeEncodeError, UnicodeDecodeError):
         raise FilenameEncodingError(path)
 
     try: