diff options
author | Neal Norwitz <nnorwitz@gmail.com> | 2003-02-09 01:10:02 (GMT) |
---|---|---|
committer | Neal Norwitz <nnorwitz@gmail.com> | 2003-02-09 01:10:02 (GMT) |
commit | cb3319f61e94af8794a51f51730dce4a9d512af3 (patch) | |
tree | ea4a3d6028434b0c0e013dfe7ad55438c181369e /Objects | |
parent | df1252dec9de0ffd20531ad58d7b0957681d8604 (diff) | |
download | cpython-cb3319f61e94af8794a51f51730dce4a9d512af3.zip cpython-cb3319f61e94af8794a51f51730dce4a9d512af3.tar.gz cpython-cb3319f61e94af8794a51f51730dce4a9d512af3.tar.bz2 |
SF patch #683187, fix universal newline problems on error
Diffstat (limited to 'Objects')
-rw-r--r-- | Objects/fileobject.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/Objects/fileobject.c b/Objects/fileobject.c index fb8ec90..5b2267b 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--) { |