to_utf8 returns what was passed in if unicode() errors because it's already encoded

This commit is contained in:
Eric Blade 2010-01-29 12:01:51 -05:00
parent 23e0611978
commit e56cb24ed1

View File

@ -42,6 +42,8 @@ def to_utf8(s):
except UnicodeDecodeError:
sys.stderr.write('Could not convert: "%s"\n' % s)
raise
except TypeError: # TypeError is raised when we give unicode() an already encoded string
return s
def to_db_utf8(s):
if not_needed: return s
@ -62,4 +64,3 @@ def to_gui(s):
except UnicodeDecodeError:
sys.stderr.write('Could not convert: "%s"\n' % s)
raise