From: Bob Halley Date: Sun, 8 May 2016 18:53:19 +0000 (-0700) Subject: Fix problems with X-Git-Tag: v1.13.0~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=537d2dd0378c1e819b8a65a341ed7dab75c5e444;p=thirdparty%2Fdnspython.git Fix problems with dns.name.from_unicode(u'\u00ff' * 60) dns.name.from_unicode(u'\\255') --- diff --git a/dns/name.py b/dns/name.py index 1fc56ed7..e8cb3513 100644 --- a/dns/name.py +++ b/dns/name.py @@ -624,14 +624,14 @@ def from_unicode(text, origin=root): edigits += 1 if edigits == 3: escaping = False - label += chr(total) + label += unichr(total) elif c in [u'.', u'\u3002', u'\uff0e', u'\uff61']: if len(label) == 0: raise EmptyLabel - if len(label) > 63: - # otherwise encodings.idna raises UnicodeError later + try: + labels.append(encodings.idna.ToASCII(label)) + except UnicodeError: raise LabelTooLong - labels.append(encodings.idna.ToASCII(label)) label = u'' elif c == u'\\': escaping = True @@ -641,11 +641,11 @@ def from_unicode(text, origin=root): label += c if escaping: raise BadEscape - if len(label) > 63: - # otherwise encodings.idna raises UnicodeError later - raise LabelTooLong if len(label) > 0: - labels.append(encodings.idna.ToASCII(label)) + try: + labels.append(encodings.idna.ToASCII(label)) + except UnicodeError: + raise LabelTooLong else: labels.append(b'')