[Python-checkins] r45401 - in python/trunk/Lib: codecs.py encodings/idna.py test/test_codecs.py (original) (raw)

walter.doerwald python-checkins at python.org
Fri Apr 14 20:25:40 CEST 2006


Author: walter.doerwald Date: Fri Apr 14 20:25:39 2006 New Revision: 45401

Modified: python/trunk/Lib/codecs.py python/trunk/Lib/encodings/idna.py python/trunk/Lib/test/test_codecs.py Log: Add a BufferedIncrementalEncoder class that can be used for implementing an incremental encoder that must retain part of the data between calls to the encode() method.

Fix the incremental encoder and decoder for the IDNA encoding.

This closes SF patch #1453235.

Modified: python/trunk/Lib/codecs.py

--- python/trunk/Lib/codecs.py (original) +++ python/trunk/Lib/codecs.py Fri Apr 14 20:25:39 2006 @@ -181,6 +181,33 @@ Resets the encoder to the initial state. """

+class BufferedIncrementalEncoder(IncrementalEncoder):

Modified: python/trunk/Lib/encodings/idna.py

--- python/trunk/Lib/encodings/idna.py (original) +++ python/trunk/Lib/encodings/idna.py Fri Apr 14 20:25:39 2006 @@ -194,13 +194,79 @@ return u".".join(result)+trailing_dot, len(input) -class IncrementalEncoder(codecs.IncrementalEncoder): - def encode(self, input, final=False): - return Codec().encode(input, self.errors)[0]

-class IncrementalDecoder(codecs.IncrementalDecoder):

+class IncrementalEncoder(codecs.BufferedIncrementalEncoder):

class StreamWriter(Codec,codecs.StreamWriter): pass

Modified: python/trunk/Lib/test/test_codecs.py

--- python/trunk/Lib/test/test_codecs.py (original) +++ python/trunk/Lib/test/test_codecs.py Fri Apr 14 20:25:39 2006 @@ -781,9 +781,18 @@ except Exception,e: raise test_support.TestFailed("Test 3.%d: %s" % (pos+1, str(e)))

-class CodecTest(unittest.TestCase):

+class IDNACodecTest(unittest.TestCase):

@@ -791,6 +800,64 @@ r.read(3) self.assertEquals(r.read(), u"")

@@ -1158,7 +1225,7 @@ PunycodeTest, UnicodeInternalTest, NameprepTest,



More information about the Python-checkins mailing list