diff -r 65f96010b35c Lib/test/test_os_jy.py --- a/Lib/test/test_os_jy.py Fri Feb 06 20:21:15 2015 -0700 +++ b/Lib/test/test_os_jy.py Fri Feb 20 14:34:11 2015 -0800 @@ -58,6 +58,21 @@ else: self.assertTrue(False) + def test_issue2068(self): + os.remove(test_support.TESTFN) + for i in range(2): + fd = os.open(test_support.TESTFN, os.O_RDWR | os.O_CREAT | os.O_APPEND) + try: + os.write(fd, bytes('one')) + os.write(fd, bytes('two')) + os.write(fd, bytes('three')) + finally: + fd.close() + + with open(test_support.TESTFN, 'rb') as f: + content = f.read() + self.assertEqual(content, 2 * b'onetwothree') + class OSDirTestCase(unittest.TestCase): diff -r 65f96010b35c src/org/python/core/io/FileIO.java --- a/src/org/python/core/io/FileIO.java Fri Feb 06 20:21:15 2015 -0700 +++ b/src/org/python/core/io/FileIO.java Fri Feb 20 14:34:11 2015 -0800 @@ -307,7 +307,7 @@ checkWritable(); try { return !emulateAppend ? fileChannel.write(buf) : - fileChannel.write(buf, fileChannel.position()); + fileChannel.write(buf, fileChannel.size()); } catch (IOException ioe) { throw Py.IOError(ioe); } @@ -344,7 +344,7 @@ if (!buf.hasRemaining()) { continue; } - if ((bufCount = fileChannel.write(buf, fileChannel.position())) == 0) { + if ((bufCount = fileChannel.write(buf, fileChannel.size())) == 0) { break; } count += bufCount;