[Jython-checkins] jython: Fix return value of io.FileIO.readinto() so EOF=0 as contract.
jeff.allen
jython-checkins at python.org
Sun Dec 9 21:29:49 CET 2012
http://hg.python.org/jython/rev/2ccd73a00a86
changeset: 6898:2ccd73a00a86
user: Jeff Allen <ja...py at farowl.co.uk>
date: Sun Dec 09 19:46:05 2012 +0000
summary:
Fix return value of io.FileIO.readinto() so EOF=0 as contract.
test_io scores now fail/error/skip = 17/18/99
files:
src/org/python/core/io/FileIO.java | 10 ++++++----
1 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/src/org/python/core/io/FileIO.java b/src/org/python/core/io/FileIO.java
--- a/src/org/python/core/io/FileIO.java
+++ b/src/org/python/core/io/FileIO.java
@@ -241,15 +241,16 @@
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}
@@ -259,7 +260,8 @@
checkClosed();
checkReadable();
try {
- return fileChannel.read(bufs);
+ long n = fileChannel.read(bufs);
+ return n > 0L ? n : 0L;
} catch (IOException ioe) {
throw Py.IOError(ioe);
}
--
Repository URL: http://hg.python.org/jython
More information about the Jython-checkins
mailing list