summaryrefslogtreecommitdiffstats
path: root/Objects/fileobject.c
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1991-12-10 14:00:03 (GMT)
committerGuido van Rossum <guido@python.org>1991-12-10 14:00:03 (GMT)
commit87e7ea72a6ef9232be9db06038943044c747971b (patch)
tree0482b0b111b4779a18f680db9a1c5bd10ca0005f /Objects/fileobject.c
parent97ff5308fe3e490aac51316cf5575c6119227cc8 (diff)
downloadcpython-87e7ea72a6ef9232be9db06038943044c747971b.zip
cpython-87e7ea72a6ef9232be9db06038943044c747971b.tar.gz
cpython-87e7ea72a6ef9232be9db06038943044c747971b.tar.bz2
Use new exceptions.
Diffstat (limited to 'Objects/fileobject.c')
-rw-r--r--Objects/fileobject.c24
1 files changed, 7 insertions, 17 deletions
diff --git a/Objects/fileobject.c b/Objects/fileobject.c
index b25615933..1f1dcae 100644
--- a/Objects/fileobject.c
+++ b/Objects/fileobject.c
@@ -95,7 +95,7 @@ newfileobject(name, mode)
#endif
f->f_fp = fopen(name, mode);
if (f->f_fp == NULL) {
- err_errno(RuntimeError);
+ err_errno(IOError);
DECREF(f);
return NULL;
}
@@ -166,7 +166,7 @@ file_close(f, args)
if (sts == EOF) {
if (errno == 0)
errno = EIO;
- return err_errno(RuntimeError);
+ return err_errno(IOError);
}
if (sts != 0)
return newintobject((long)sts);
@@ -198,7 +198,7 @@ file_seek(f, args)
if (fseek(f->f_fp, offset, (int)whence) != 0) {
if (errno == 0)
errno = EIO;
- return err_errno(RuntimeError);
+ return err_errno(IOError);
}
INCREF(None);
return None;
@@ -219,7 +219,7 @@ file_tell(f, args)
if (offset == -1L) {
if (errno == 0)
errno = EIO;
- return err_errno(RuntimeError);
+ return err_errno(IOError);
}
return newintobject(offset);
}
@@ -237,7 +237,7 @@ file_flush(f, args)
if (fflush(f->f_fp) != 0) {
if (errno == 0)
errno = EIO;
- return err_errno(RuntimeError);
+ return err_errno(IOError);
}
INCREF(None);
return None;
@@ -441,7 +441,6 @@ file_write(f, args)
object *args;
{
int n, n2;
- char *s;
if (f->f_fp == NULL) {
err_badarg();
return NULL;
@@ -452,20 +451,11 @@ file_write(f, args)
}
f->f_softspace = 0;
errno = 0;
- n = getstringsize(args);
- s = getstringvalue(args);
- if (n > BUFSIZ) {
- fflush(f->f_fp);
- n2 = write(fileno(f->f_fp), s, n);
- fflush(f->f_fp);
- }
- else {
- n2 = fwrite(s, 1, n, f->f_fp);
- }
+ n2 = fwrite(getstringvalue(args), 1, n = getstringsize(args), f->f_fp);
if (n2 != n) {
if (errno == 0)
errno = EIO;
- err_errno(RuntimeError);
+ err_errno(IOError);
return NULL;
}
INCREF(None);