[Python-checkins] cpython (2.7): Circumventing a bug in glibc (issue #17976).

serhiy.storchaka python-checkins at python.org
Tue Dec 17 16:32:49 CET 2013


http://hg.python.org/cpython/rev/24a043355050
changeset:   88027:24a043355050
branch:      2.7
parent:      88024:debdfa44f020
user:        Serhiy Storchaka <storchaka at gmail.com>
date:        Tue Dec 17 17:32:20 2013 +0200
summary:
  Circumventing a bug in glibc (issue #17976).
Patch by Jaakko Moisio.

files:
  Objects/fileobject.c |  8 +++++---
  1 files changed, 5 insertions(+), 3 deletions(-)


diff --git a/Objects/fileobject.c b/Objects/fileobject.c
--- a/Objects/fileobject.c
+++ b/Objects/fileobject.c
@@ -1804,7 +1804,7 @@
     const char *s;
     Py_ssize_t n, n2;
     PyObject *encoded = NULL;
-    int err = 0;
+    int err_flag = 0, err;
 
     if (f->f_fp == NULL)
         return err_closed();
@@ -1850,13 +1850,15 @@
     FILE_BEGIN_ALLOW_THREADS(f)
     errno = 0;
     n2 = fwrite(s, 1, n, f->f_fp);
-    if (n2 != n || ferror(f->f_fp))
+    if (n2 != n || ferror(f->f_fp)) {
+        err_flag = 1;
         err = errno;
+    }
     FILE_END_ALLOW_THREADS(f)
     Py_XDECREF(encoded);
     if (f->f_binary)
         PyBuffer_Release(&pbuf);
-    if (err) {
+    if (err_flag) {
         errno = err;
         PyErr_SetFromErrno(PyExc_IOError);
         clearerr(f->f_fp);

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list