summaryrefslogtreecommitdiff
path: root/Objects/fileobject.c
diff options
context:
space:
mode:
authorNeal Norwitz <nnorwitz@gmail.com>2003-02-09 01:10:02 +0000
committerNeal Norwitz <nnorwitz@gmail.com>2003-02-09 01:10:02 +0000
commit40db3c203f26d1661cba1942d8131b48302ca598 (patch)
treeca8ee40d9bfbc6d771283dec063b78d1726bf0ac /Objects/fileobject.c
parent750ac2f15456f18ab0c81357cf1831340f9a91d3 (diff)
downloadcpython-40db3c203f26d1661cba1942d8131b48302ca598.tar.gz
SF patch #683187, fix universal newline problems on error
Diffstat (limited to 'Objects/fileobject.c')
-rw-r--r--Objects/fileobject.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/Objects/fileobject.c b/Objects/fileobject.c
index fb8ec90cfe..5b2267b417 100644
--- a/Objects/fileobject.c
+++ b/Objects/fileobject.c
@@ -2278,7 +2278,7 @@ Py_UniversalNewlineFread(char *buf, size_t n,
if (!fobj || !PyFile_Check(fobj)) {
errno = ENXIO; /* What can you do... */
- return -1;
+ return 0;
}
if (!f->f_univ_newline)
return fread(buf, 1, n, stream);
@@ -2294,6 +2294,9 @@ Py_UniversalNewlineFread(char *buf, size_t n,
nread = fread(dst, 1, n, stream);
assert(nread <= n);
+ if (nread == 0)
+ break;
+
n -= nread; /* assuming 1 byte out for each in; will adjust */
shortread = n != 0; /* true iff EOF or error */
while (nread--) {