summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1991-11-12 15:42:49 (GMT)
committerGuido van Rossum <guido@python.org>1991-11-12 15:42:49 (GMT)
commit8aff84a100045f65125fb270b264fe8947c414f1 (patch)
tree08a5b52a02e13989d35b6cc815482166633118e2 /Objects
parent19f1b8261efd9d0a30a7551d2e2a55288e92a6d6 (diff)
downloadcpython-8aff84a100045f65125fb270b264fe8947c414f1.zip
cpython-8aff84a100045f65125fb270b264fe8947c414f1.tar.gz
cpython-8aff84a100045f65125fb270b264fe8947c414f1.tar.bz2
Call write(fileno(fp), ...) instead of fwrite for LARGE writes.
Diffstat (limited to 'Objects')
-rw-r--r--Objects/fileobject.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/Objects/fileobject.c b/Objects/fileobject.c
index 14266a7..b25615933 100644
--- a/Objects/fileobject.c
+++ b/Objects/fileobject.c
@@ -441,6 +441,7 @@ file_write(f, args)
object *args;
{
int n, n2;
+ char *s;
if (f->f_fp == NULL) {
err_badarg();
return NULL;
@@ -451,7 +452,16 @@ file_write(f, args)
}
f->f_softspace = 0;
errno = 0;
- n2 = fwrite(getstringvalue(args), 1, n = getstringsize(args), f->f_fp);
+ 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);
+ }
if (n2 != n) {
if (errno == 0)
errno = EIO;