mirror of
https://github.com/Hopiu/linkchecker.git
synced 2026-05-03 20:34:43 +00:00
Python3: fix strformat ascii_safe() and unicode_safe()
This commit is contained in:
parent
ecba4e7ac8
commit
a1c6c4935e
1 changed files with 3 additions and 3 deletions
|
|
@ -56,10 +56,10 @@ def unicode_safe (s, encoding=i18n.default_encoding, errors='replace'):
|
|||
@rtype: unicode
|
||||
"""
|
||||
assert s is not None, "argument to unicode_safe was None"
|
||||
if isinstance(s, unicode):
|
||||
if isinstance(s, str_text):
|
||||
# s is already unicode, nothing to do
|
||||
return s
|
||||
return unicode(str(s), encoding, errors)
|
||||
return str_text(bytes(s), encoding, errors)
|
||||
|
||||
|
||||
def ascii_safe (s):
|
||||
|
|
@ -71,7 +71,7 @@ def ascii_safe (s):
|
|||
@return: encoded ASCII version of s, or None if s was None
|
||||
@rtype: string
|
||||
"""
|
||||
if isinstance(s, unicode):
|
||||
if isinstance(s, str_text):
|
||||
s = s.encode('ascii', 'ignore')
|
||||
return s
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue