Update and integrate Suelta.
This commit is contained in:
@@ -20,19 +20,13 @@ import sys
|
||||
import stringprep
|
||||
import unicodedata
|
||||
|
||||
from sleekxmpp.util import unicode
|
||||
|
||||
|
||||
class StringPrepError(UnicodeError):
|
||||
pass
|
||||
|
||||
|
||||
def to_unicode(data):
|
||||
"""Ensure that a given string is Unicode, regardless of Python version."""
|
||||
if sys.version_info < (3, 0):
|
||||
return unicode(data)
|
||||
else:
|
||||
return str(data)
|
||||
|
||||
|
||||
def b1_mapping(char):
|
||||
"""Map characters that are commonly mapped to nothing."""
|
||||
return '' if stringprep.in_table_b1(char) else None
|
||||
@@ -143,7 +137,7 @@ def create(nfkc=True, bidi=True, mappings=None,
|
||||
"""
|
||||
def profile(data, query=False):
|
||||
try:
|
||||
data = to_unicode(data)
|
||||
data = unicode(data)
|
||||
except UnicodeError:
|
||||
raise StringPrepError
|
||||
|
||||
|
||||
Reference in New Issue
Block a user