Skip to content

Commit

Permalink
Fix regressions from removing Python 2 support
Browse files Browse the repository at this point in the history
  • Loading branch information
kjd committed Jan 1, 2021
1 parent 229f123 commit 82f7b70
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 11 deletions.
10 changes: 1 addition & 9 deletions idna/codec.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]:
Expand Down
6 changes: 4 additions & 2 deletions tests/test_idna_uts46.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 82f7b70

Please sign in to comment.