diff options
author | Antoine Pitrou <solipsis@pitrou.net> | 2010-08-01 20:12:04 (GMT) |
---|---|---|
committer | Antoine Pitrou <solipsis@pitrou.net> | 2010-08-01 20:12:04 (GMT) |
commit | 1e2abe73222bf9b1721afa61fb8dde71aca154d0 (patch) | |
tree | 3810545a4ff6e5d97b7c9479e92a33bdb8420b0c /Lib/test/test_bz2.py | |
parent | c685068004d8a64ddac87c6facae376200c14dc7 (diff) | |
download | cpython-1e2abe73222bf9b1721afa61fb8dde71aca154d0.zip cpython-1e2abe73222bf9b1721afa61fb8dde71aca154d0.tar.gz cpython-1e2abe73222bf9b1721afa61fb8dde71aca154d0.tar.bz2 |
Merged revisions 83440 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k
........
r83440 | antoine.pitrou | 2010-08-01 22:08:46 +0200 (dim., 01 août 2010) | 4 lines
Issue #8397: Raise an error when attempting to mix iteration and regular
reads on a BZ2File object, rather than returning incorrect results.
........
Diffstat (limited to 'Lib/test/test_bz2.py')
-rw-r--r-- | Lib/test/test_bz2.py | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/Lib/test/test_bz2.py b/Lib/test/test_bz2.py index 9a9afa6..bfcb02a 100644 --- a/Lib/test/test_bz2.py +++ b/Lib/test/test_bz2.py @@ -300,6 +300,24 @@ class BZ2FileTest(BaseTest): finally: f.close() + def testMixedIterationReads(self): + # Issue #8397: mixed iteration and reads should be forbidden. + f = bz2.BZ2File(self.filename, 'wb') + try: + # The internal buffer size is hard-wired to 8192 bytes, we must + # write out more than that for the test to stop half through + # the buffer. + f.write(self.TEXT * 100) + finally: + f.close() + f = bz2.BZ2File(self.filename, 'rb') + try: + next(f) + self.assertRaises(ValueError, f.read) + self.assertRaises(ValueError, f.readline) + self.assertRaises(ValueError, f.readlines) + finally: + f.close() class BZ2CompressorTest(BaseTest): def testCompress(self): |