diff -r 35da5d848ffd Lib/encodings/idna.py --- a/Lib/encodings/idna.py Mon Sep 23 23:24:38 2013 +0300 +++ b/Lib/encodings/idna.py Tue Sep 24 15:08:59 2013 +0000 @@ -88,7 +88,7 @@ raise UnicodeError("label empty or too long") # Step 5: Check ACE prefix - if label.startswith(sace_prefix): + if label.lower().startswith(sace_prefix): raise UnicodeError("Label starts with ACE prefix") # Step 6: Encode with PUNYCODE @@ -121,7 +121,7 @@ except UnicodeError: raise UnicodeError("Invalid character in IDN label") # Step 3: Check for ACE prefix - if not label.startswith(ace_prefix): + if not label.lower().startswith(ace_prefix): return str(label, "ascii") # Step 4: Remove ACE prefix @@ -194,7 +194,7 @@ # XXX obviously wrong, see #3232 input = bytes(input) - if ace_prefix not in input: + if ace_prefix not in input.lower(): # Fast path try: return input.decode('ascii'), len(input) diff -r 35da5d848ffd Lib/test/test_codecs.py --- a/Lib/test/test_codecs.py Mon Sep 23 23:24:38 2013 +0300 +++ b/Lib/test/test_codecs.py Tue Sep 24 15:08:59 2013 +0000 @@ -1371,6 +1371,7 @@ self.assertEqual(str(b"python.org.", "idna"), "python.org.") self.assertEqual(str(b"xn--pythn-mua.org", "idna"), "pyth\xf6n.org") self.assertEqual(str(b"xn--pythn-mua.org.", "idna"), "pyth\xf6n.org.") + self.assertEqual(str(b"XN--pythn-mua.org.", "idna"), "pyth\xf6n.org.") def test_builtin_encode(self): self.assertEqual("python.org".encode("idna"), b"python.org")