diff --git a/idna/codec.py b/idna/codec.py index ece9bb3..30fe72f 100644 --- a/idna/codec.py +++ b/idna/codec.py @@ -67,15 +67,7 @@ def _buffer_decode(self, data, errors, final): if not data: return ('', 0) - # IDNA allows decoding to operate on Unicode strings, too. - if isinstance(data, unicode): - labels = _unicode_dots_re.split(data) - else: - # Must be ASCII string - data = str(data) - unicode(data, 'ascii') - labels = data.split('.') - + labels = _unicode_dots_re.split(data) trailing_dot = '' if labels: if not labels[-1]: diff --git a/tests/test_idna_uts46.py b/tests/test_idna_uts46.py index 2e7ad93..fd1996d 100755 --- a/tests/test_idna_uts46.py +++ b/tests/test_idna_uts46.py @@ -1,10 +1,13 @@ """Tests for TR46 code.""" import os.path +import re import unittest import idna +_RE_UNICODE = re.compile("\\\\u([0-9a-fA-F]{4})") +_RE_SURROGATE = re.compile("[\uD800-\uDBFF][\uDC00-\uDFFF]") _SKIP_TESTS = [ # These are strings that are illegal in IDNA 2008. Older versions of the UTS-46 test suite # had these denoted with the 'NV8' marker but this has been removed, so we need to manually @@ -109,8 +112,7 @@ class TestIdnaTest(unittest.TestCase): def __init__(self, lineno=None, fields=None): super().__init__() self.lineno = lineno - if fields: - self.fields = fields + self.fields = fields def id(self): return '{}.{}'.format(super().id(), self.lineno)