summaryrefslogtreecommitdiffstats
path: root/Lib/encodings
diff options
context:
space:
mode:
authorMartin v. Löwis <martin@v.loewis.de>2005-08-25 11:03:38 (GMT)
committerMartin v. Löwis <martin@v.loewis.de>2005-08-25 11:03:38 (GMT)
commit8b59514e5799fc41e84afeef0892219d9aa3e872 (patch)
tree19b50ad761d07e49c156f94cf20de31345132350 /Lib/encodings
parent8246c439a8246093b03e3987d6c1496ebe73b81c (diff)
downloadcpython-8b59514e5799fc41e84afeef0892219d9aa3e872.zip
cpython-8b59514e5799fc41e84afeef0892219d9aa3e872.tar.gz
cpython-8b59514e5799fc41e84afeef0892219d9aa3e872.tar.bz2
Make IDNA return an empty string when the input is empty. Fixes #1163178.
Will backport to 2.4.
Diffstat (limited to 'Lib/encodings')
-rw-r--r--Lib/encodings/idna.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/Lib/encodings/idna.py b/Lib/encodings/idna.py
index 4814215..f8a31d8 100644
--- a/Lib/encodings/idna.py
+++ b/Lib/encodings/idna.py
@@ -149,6 +149,9 @@ class Codec(codecs.Codec):
# IDNA is quite clear that implementations must be strict
raise UnicodeError, "unsupported error handling "+errors
+ if not input:
+ return "", 0
+
result = []
labels = dots.split(input)
if labels and len(labels[-1])==0:
@@ -166,6 +169,9 @@ class Codec(codecs.Codec):
if errors != 'strict':
raise UnicodeError, "Unsupported error handling "+errors
+ if not input:
+ return u"", 0
+
# IDNA allows decoding to operate on Unicode strings, too.
if isinstance(input, unicode):
labels = dots.split(input)