summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2010-08-01 20:16:12 (GMT)
committerAntoine Pitrou <solipsis@pitrou.net>2010-08-01 20:16:12 (GMT)
commitcdb63fbc57f0476d2bc332c08d81360910e722da (patch)
treeabb2be29162da59c36481d28fc97c23f8d6adca2 /Lib
parent1fa5e059a4d2fc118e798d0fe1e185894aebe0c6 (diff)
downloadcpython-cdb63fbc57f0476d2bc332c08d81360910e722da.zip
cpython-cdb63fbc57f0476d2bc332c08d81360910e722da.tar.gz
cpython-cdb63fbc57f0476d2bc332c08d81360910e722da.tar.bz2
Merged revisions 83442 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/release27-maint ................ r83442 | antoine.pitrou | 2010-08-01 22:13:11 +0200 (dim., 01 août 2010) | 10 lines 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')
-rw-r--r--Lib/test/test_bz2.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/Lib/test/test_bz2.py b/Lib/test/test_bz2.py
index e1e5a28..ee7e886 100644
--- a/Lib/test/test_bz2.py
+++ b/Lib/test/test_bz2.py
@@ -302,6 +302,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):