str() for unicode_safe objects

git-svn-id: https://linkchecker.svn.sourceforge.net/svnroot/linkchecker/trunk/linkchecker@2324 e7d03fd6-7b0d-0410-9947-9c21f3af8025
This commit is contained in:
calvin 2005-02-18 11:29:58 +00:00
parent daf6f351c4
commit bf89b8e9a9

View file

@ -33,16 +33,16 @@ def unicode_safe (s, encoding="iso-8859-1"):
characters of the given encoding will be ignored.
@param s: the string to be decoded
@type s: unicode or encoded string
@type s: any object except None
@return: if s is already unicode, return s unchanged; else return
decoded unicode string
decoded unicode string of str(s)
@rtype: unicode
"""
assert s is not None, "argument to unicode_safe was None"
if isinstance(s, unicode):
# s is already unicode, nothing to do
return s
return unicode(s, encoding, "ignore")
return unicode(str(s), encoding, "ignore")
def url_unicode_split (url):