Issue #5433: Excessive newline detection optimization in IncrementalNewlineDecoder

This commit is contained in:
Antoine Pitrou 2009-03-06 23:40:56 +00:00
parent 2db74c2412
commit 66913e2213
2 changed files with 43 additions and 12 deletions

View file

@ -1915,6 +1915,19 @@ class IncrementalNewlineDecoderTest(unittest.TestCase):
decoder = self.IncrementalNewlineDecoder(decoder, translate=True)
self.check_newline_decoding_utf8(decoder)
def test_newline_bytes(self):
# Issue 5433: Excessive optimization in IncrementalNewlineDecoder
def _check(dec):
self.assertEquals(dec.newlines, None)
self.assertEquals(dec.decode("\u0D00"), "\u0D00")
self.assertEquals(dec.newlines, None)
self.assertEquals(dec.decode("\u0A00"), "\u0A00")
self.assertEquals(dec.newlines, None)
dec = self.IncrementalNewlineDecoder(None, translate=False)
_check(dec)
dec = self.IncrementalNewlineDecoder(None, translate=True)
_check(dec)
class CIncrementalNewlineDecoderTest(IncrementalNewlineDecoderTest):
pass