Enhance unicodify to correctly handle non-string input.

This commit is contained in:
Jeremy Goecks
2013-05-30 17:17:23 -04:00
parent 758189ca9e
commit 4ef01c2820
+2 -1
View File
@@ -480,10 +480,11 @@ def unicodify( value, encoding=DEFAULT_ENCODING, error='replace', default=None )
"""
Returns a unicode string or None
"""
if isinstance( value, unicode ):
return value
try:
return unicode( value, encoding, error )
return unicode( str( value ), encoding, error )
except:
return default