diff --git a/Lib/test/test_file.py b/Lib/test/test_file.py index 2d791a55c07..96f6da20235 100644 --- a/Lib/test/test_file.py +++ b/Lib/test/test_file.py @@ -120,6 +120,8 @@ class AutoFileTests(unittest.TestCase): except: self.assertEquals(self.f.__exit__(*sys.exc_info()), None) + def testReadWhenWriting(self): + self.assertRaises(IOError, self.f.read) class OtherFileTests(unittest.TestCase): diff --git a/Misc/NEWS b/Misc/NEWS index 4eba4f6d2a2..a305843c448 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -12,6 +12,9 @@ What's New in Python 2.6.2 Core and Builtins ----------------- +- Added test case to ensure attempts to read from a file opened for writing + fail. + - Issue #4597: Fixed several opcodes that weren't always propagating exceptions.