Commits

Jeff Allen  committed 2ccd73a Draft

Fix return value of io.FileIO.readinto() so EOF=0 as contract.
test_io scores now fail/error/skip = 17/18/99

  • Participants
  • Parent commits 580ce86

Comments (0)

Files changed (1)

File src/org/python/core/io/FileIO.java

         checkClosed();
         checkReadable();
         try {
-            return fileChannel.read(buf);
+            int n = fileChannel.read(buf);
+            return n > 0 ? n : 0;
         } catch (IOException ioe) {
             throw Py.IOError(ioe);
         }
     }
 
     /**
-     * Read bytes into each of the specified ByteBuffers via scatter
-     * i/o.
+     * Read bytes into each of the specified ByteBuffers via scatter i/o. Returns number of bytes
+     * read (0 for EOF).
      *
      * @param bufs {@inheritDoc}
      * @return {@inheritDoc}
         checkClosed();
         checkReadable();
         try {
-            return fileChannel.read(bufs);
+            long n = fileChannel.read(bufs);
+            return n > 0L ? n : 0L;
         } catch (IOException ioe) {
             throw Py.IOError(ioe);
         }