summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohn Garland <johnnybg+deluge@gmail.com>2010-06-07 20:05:34 +1000
committerJohn Garland <johnnybg+deluge@gmail.com>2010-06-07 20:18:37 +1000
commitbd775d0d401686e260dccce94ca61f4edcf3a452 (patch)
treec8c5e0319d7284cfb2359faca80b5042841371be
parent7fb3c3c04cf683ae19fa2a2dc1b4453845249bc6 (diff)
downloaddeluge-bd775d0d401686e260dccce94ca61f4edcf3a452.tar.gz
deluge-bd775d0d401686e260dccce94ca61f4edcf3a452.tar.bz2
deluge-bd775d0d401686e260dccce94ca61f4edcf3a452.zip
Only encode if necessary
-rw-r--r--deluge/ui/console/colors.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/deluge/ui/console/colors.py b/deluge/ui/console/colors.py
index 3b9455446..83465737d 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