summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Lib/encodings/idna.py6
-rw-r--r--Lib/test/test_codecs.py6
-rw-r--r--Misc/NEWS2
3 files changed, 14 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)
diff --git a/Lib/test/test_codecs.py b/Lib/test/test_codecs.py
index 5f799e0..5189e80 100644
--- a/Lib/test/test_codecs.py
+++ b/Lib/test/test_codecs.py
@@ -630,6 +630,12 @@ class CodecTest(unittest.TestCase):
def test_builtin(self):
self.assertEquals(unicode("python.org", "idna"), u"python.org")
+ def test_stream(self):
+ import StringIO
+ r = codecs.getreader("idna")(StringIO.StringIO("abc"))
+ r.read(3)
+ self.assertEquals(r.read(), u"")
+
class CodecsModuleTest(unittest.TestCase):
def test_decode(self):
diff --git a/Misc/NEWS b/Misc/NEWS
index 20e1f89..89efcad 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -193,6 +193,8 @@ Extension Modules
Library
-------
+- Bug #1163178: Make IDNA return an empty string when the input is empty.
+
- Patch #848017: Make Cookie more RFC-compliant. Use CRLF as default output
separator and do not output trailing semicola.