Skip to content

Commit

Permalink
Change error handling. Call clearerr() more often.
Browse files Browse the repository at this point in the history
  • Loading branch information
gvanrossum committed Mar 4, 1992
1 parent 299a734 commit febd551
Showing 1 changed file with 11 additions and 15 deletions.
26 changes: 11 additions & 15 deletions Objects/fileobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand All @@ -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);
}
Expand All @@ -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;
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit febd551

Please sign in to comment.