cpython: 33c27b76a4d0 (original) (raw)
Mercurial > cpython
changeset 88019:33c27b76a4d0 2.7
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. [#17976]
Serhiy Storchaka storchaka@gmail.com | |
---|---|
date | Tue, 17 Dec 2013 14:40:06 +0200 |
parents | 4de09cbd3b97 |
children | 237deaf9ba64 |
files | Lib/test/test_file2k.py Misc/ACKS Misc/NEWS Objects/fileobject.c |
diffstat | 4 files changed, 18 insertions(+), 1 deletions(-)[+] [-] Lib/test/test_file2k.py 8 Misc/ACKS 1 Misc/NEWS 4 Objects/fileobject.c 6 |
line wrap: on
line diff
--- a/Lib/test/test_file2k.py +++ b/Lib/test/test_file2k.py @@ -415,6 +415,14 @@ class OtherFileTests(unittest.TestCase): finally: os.unlink(TESTFN)
- @unittest.skipUnless(os.name == 'posix', 'test requires a posix system.')
- def test_write_full(self):
# Issue #17976[](#l1.9)
with open('/dev/full', 'w', 1) as f:[](#l1.10)
with self.assertRaises(IOError):[](#l1.11)
f.write('hello')[](#l1.12)
f.write('\n')[](#l1.13)
+ class FileSubclassTests(unittest.TestCase): def testExit(self):
--- a/Misc/ACKS +++ b/Misc/ACKS @@ -710,6 +710,7 @@ Dustin J. Mitchell Dom Mitchell Florian Mladitsch Doug Moen +Jaakko Moisio The Dragon De Monsyne Skip Montanaro Paul Moore
--- a/Misc/NEWS +++ b/Misc/NEWS @@ -9,6 +9,10 @@ What's New in Python 2.7.7? Core and Builtins ----------------- +- Issue #17976: Fixed potential problem with file.write() not detecting IO error
- Issue #14432: Generator now clears the borrowed reference to the thread state. Fix a crash when a generator is created in a C thread that is destroyed while the generator is still used. The issue was that a generator
--- a/Objects/fileobject.c +++ b/Objects/fileobject.c @@ -1804,6 +1804,7 @@ file_write(PyFileObject *f, PyObject *ar const char *s; Py_ssize_t n, n2; PyObject *encoded = NULL;
if (f->f_fp == NULL) return err_closed(); @@ -1849,11 +1850,14 @@ file_write(PyFileObject *f, PyObject *ar FILE_BEGIN_ALLOW_THREADS(f) errno = 0; n2 = fwrite(s, 1, n, f->f_fp);