summaryrefslogtreecommitdiffstats
path: root/Objects/fileobject.c
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1992-03-04 16:39:24 (GMT)
committerGuido van Rossum <guido@python.org>1992-03-04 16:39:24 (GMT)
commitfebd551bab28b3a90b838e4782726d9fb3a587c7 (patch)
treee9be20e10ce7bdc2bd43a5b1bce3d3d30c6023ae /Objects/fileobject.c
parent299a734744fb48132ca31dcac358a70b315b0d1c (diff)
downloadcpython-febd551bab28b3a90b838e4782726d9fb3a587c7.zip
cpython-febd551bab28b3a90b838e4782726d9fb3a587c7.tar.gz
cpython-febd551bab28b3a90b838e4782726d9fb3a587c7.tar.bz2
Change error handling. Call clearerr() more often.
Diffstat (limited to 'Objects/fileobject.c')
-rw-r--r--Objects/fileobject.c26
1 files changed, 11 insertions, 15 deletions
diff --git a/Objects/fileobject.c b/Objects/fileobject.c
index e925b4d..8e35e7e 100644
--- a/Objects/fileobject.c
+++ b/Objects/fileobject.c
@@ -164,11 +164,8 @@ file_close(f, args)
sts = (*f->f_close)(f->f_fp);
f->f_fp = NULL;
}
- if (sts == EOF) {
- if (errno == 0)
- errno = EIO;
+ if (sts == EOF)
return err_errno(IOError);
- }
if (sts != 0)
return newintobject((long)sts);
INCREF(None);
@@ -197,9 +194,9 @@ file_seek(f, args)
}
errno = 0;
if (fseek(f->f_fp, offset, (int)whence) != 0) {
- if (errno == 0)
- errno = EIO;
- return err_errno(IOError);
+ err_errno(IOError);
+ clearerr(f->f_fp);
+ return NULL;
}
INCREF(None);
return None;
@@ -218,9 +215,9 @@ file_tell(f, args)
errno = 0;
offset = ftell(f->f_fp);
if (offset == -1L) {
- if (errno == 0)
- errno = EIO;
- return err_errno(IOError);
+ err_errno(IOError);
+ clearerr(f->f_fp);
+ return NULL;
}
return newintobject(offset);
}
@@ -236,9 +233,9 @@ file_flush(f, args)
}
errno = 0;
if (fflush(f->f_fp) != 0) {
- if (errno == 0)
- errno = EIO;
- return err_errno(IOError);
+ err_errno(IOError);
+ clearerr(f->f_fp);
+ return NULL;
}
INCREF(None);
return None;
@@ -455,9 +452,8 @@ file_write(f, args)
errno = 0;
n2 = fwrite(getstringvalue(args), 1, n = getstringsize(args), f->f_fp);
if (n2 != n) {
- if (errno == 0)
- errno = EIO;
err_errno(IOError);
+ clearerr(f->f_fp);
return NULL;
}
INCREF(None);