Module: deluge
Branch: master
Commit: 87879ab3b861c0be61b8b67c89cde5e95f632f8b

Author: John Garland <[email protected]>
Date:   Mon Jun  7 20:05:34 2010 +1000

Only encode if necessary

---

 deluge/ui/console/colors.py |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/deluge/ui/console/colors.py b/deluge/ui/console/colors.py
index 3b94554..8346573 100644
--- a/deluge/ui/console/colors.py
+++ b/deluge/ui/console/colors.py
@@ -126,7 +126,8 @@ def get_line_length(line, encoding="UTF-8"):
     if line.count("{!") != line.count("!}"):
         raise BadColorString("Number of {! is not equal to number of !}")
 
-    line = line.encode(encoding, "replace")
+    if isinstance(line, unicode):
+        line = line.encode(encoding, "replace")
 
     # Remove all the color tags
     line = strip_colors(line)
@@ -146,7 +147,8 @@ def parse_color_string(s, encoding="UTF-8"):
     if s.count("{!") != s.count("!}"):
         raise BadColorString("Number of {! is not equal to number of !}")
 
-    s = s.encode(encoding, "replace")
+    if isinstance(s, unicode):
+        s = s.encode(encoding, "replace")
 
     ret = []
     # Keep track of where the strings

-- 
You received this message because you are subscribed to the Google Groups 
"deluge-commit" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/deluge-commit?hl=en.

Reply via email to