Issue #17976: Fixed potential problem with file.write() not detecting IO error
by inspecting the return value of fwrite(). Based on patches by Jaakko Moisio
and test by Victor Stinner.
diff --git a/Lib/test/test_file2k.py b/Lib/test/test_file2k.py
index 0c633b4..5b90852 100644
--- a/Lib/test/test_file2k.py
+++ b/Lib/test/test_file2k.py
@@ -415,6 +415,14 @@
finally:
os.unlink(TESTFN)
+ @unittest.skipUnless(os.name == 'posix', 'test requires a posix system.')
+ def test_write_full(self):
+ # Issue #17976
+ with open('/dev/full', 'w', 1) as f:
+ with self.assertRaises(IOError):
+ f.write('hello')
+ f.write('\n')
+
class FileSubclassTests(unittest.TestCase):
def testExit(self):