summaryrefslogtreecommitdiff
path: root/debian/patches/fix-unicodeencode-error
blob: 821ceb985839580da704e4eff4b3fbf843224a88 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
Description: fix for _format arg function raising UnicodeDecodeError if DEFAULT_ENCODING cannot encode unicode characters
Author: Ben Carrillo <ben@futeisha.org>
Bug: XXX
Forwarded: yes
--- a/sh.py
+++ b/sh.py
@@ -561,7 +561,11 @@
             # if the argument is already unicode, or a number or whatever,
             # this first call will fail.  
             try: arg = unicode(arg, DEFAULT_ENCODING).encode(DEFAULT_ENCODING)
-            except TypeError: arg = unicode(arg).encode(DEFAULT_ENCODING)
+            except TypeError:
+                try:
+                    arg = unicode(arg).encode(DEFAULT_ENCODING)
+                except UnicodeEncodeError:
+                    arg = unicode(arg).encode('utf-8')
         return arg