From: <pj...@us...> - 2008-07-29 22:40:08
|
Revision: 5021 http://jython.svn.sourceforge.net/jython/?rev=5021&view=rev Author: pjenvey Date: 2008-07-29 22:40:05 +0000 (Tue, 29 Jul 2008) Log Message: ----------- fix readChunk reading more than CHUNK_SIZE, which'll blow up packReadahead Modified Paths: -------------- branches/asm/Lib/test/test_file_newlines.py branches/asm/src/org/python/core/io/TextIOBase.java Modified: branches/asm/Lib/test/test_file_newlines.py =================================================================== --- branches/asm/Lib/test/test_file_newlines.py 2008-07-29 22:33:56 UTC (rev 5020) +++ branches/asm/Lib/test/test_file_newlines.py 2008-07-29 22:40:05 UTC (rev 5021) @@ -27,13 +27,14 @@ data = CRLF_TEST write_mode = 'wb' mode = 'r' + bufsize = -1 def setUp(self): self.filename = tempfile.mktemp() - self.write_fp = open(self.filename, self.write_mode) + self.write_fp = open(self.filename, self.write_mode, self.bufsize) self.write_fp.write(self.data) self.write_fp.flush() - self.fp = open(self.filename, self.mode) + self.fp = open(self.filename, self.mode, self.bufsize) def tearDown(self): if self.write_fp: @@ -259,6 +260,17 @@ read_data = data +class UniversalCRAtReadaheadBoundaryTestCase(BaseTestCase): + + mode = 'U' + bufsize = 0 + data = ('-' * 1023) + '\r\n' + ('-' * 10233) + + def test_read_cr_at_boundary(self): + # Used to raise a BufferOverflowException w/ bufsize of 0 + read(self.fp, ('-' * 1023) + '\n', 1024) + + class WriteTextNewlinesTestCase(BaseTestCase): write_mode = 'w' @@ -344,6 +356,7 @@ UniversalReadaheadBoundary3TestCase, UniversalReadaheadBoundary4TestCase, UniversalReadaheadBoundary5TestCase, + UniversalCRAtReadaheadBoundaryTestCase, WriteTextNewlinesTestCase, ReadUniversalNewlinesTestCase, WriteUniversalNewlinesTestCase] Modified: branches/asm/src/org/python/core/io/TextIOBase.java =================================================================== --- branches/asm/src/org/python/core/io/TextIOBase.java 2008-07-29 22:33:56 UTC (rev 5020) +++ branches/asm/src/org/python/core/io/TextIOBase.java 2008-07-29 22:40:05 UTC (rev 5021) @@ -227,6 +227,10 @@ // Prepare the readahead for reading readahead.clear(); + if (readahead.remaining() > CHUNK_SIZE) { + // Limit potential full reads on a resized readahead to CHUNK_SIZE + readahead.limit(readahead.position() + CHUNK_SIZE); + } bufferedIO.read1(readahead); readahead.flip(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |