From: <pj...@us...> - 2010-03-21 21:35:20
|
Revision: 6988 http://jython.svn.sourceforge.net/jython/?rev=6988&view=rev Author: pjenvey Date: 2010-03-21 21:35:14 +0000 (Sun, 21 Mar 2010) Log Message: ----------- can't use FileOutputStreams for O_APPEND in 'a+' mode because the underlying file isn't readable fixes #1576 Modified Paths: -------------- trunk/jython/Lib/test/test_file_jy.py trunk/jython/NEWS trunk/jython/src/org/python/core/io/FileIO.java Modified: trunk/jython/Lib/test/test_file_jy.py =================================================================== --- trunk/jython/Lib/test/test_file_jy.py 2010-03-21 17:52:36 UTC (rev 6987) +++ trunk/jython/Lib/test/test_file_jy.py 2010-03-21 21:35:14 UTC (rev 6988) @@ -14,13 +14,8 @@ os.remove(test_support.TESTFN) def test_append(self): - self._test_append('ab') - - def test_appendplus(self): - self._test_append('a+') - - def _test_append(self, mode): # http://bugs.jython.org/issue1466 + mode = 'ab' fp1 = open(test_support.TESTFN, mode) fp1.write('test1\n') fp2 = open(test_support.TESTFN, mode) @@ -30,7 +25,15 @@ with open(test_support.TESTFN) as fp: self.assertEqual('test1\ntest2\n', fp.read()) + def test_appendplus(self): + # regression with the test_append fix: + # http://bugs.jython.org/issue1576 + with open(test_support.TESTFN, 'ab+') as fp: + fp.write('test1\n') + fp.seek(0) + self.assertEqual(fp.read(), 'test1\n') + def test_main(): test_support.run_unittest(FileTestCase) Modified: trunk/jython/NEWS =================================================================== --- trunk/jython/NEWS 2010-03-21 17:52:36 UTC (rev 6987) +++ trunk/jython/NEWS 2010-03-21 21:35:14 UTC (rev 6988) @@ -17,6 +17,7 @@ - [ 1511 ] PySet doesn't support Java serialization - [ 1426 ] JSR 223 Bindings changes not taking effect and leaking between threads; unnecessary synchronization - [ 1548 ] Parentheses in CLASSPATH cause errors in jython.bat + - [ 1576 ] files opened in 'a+' mode not readable - Fix runtime issues during exitfuncs triggered via SystemRestart (such as during Django or Pylons development mode reloading) - Fix pickling of collections.defaultdict objects Modified: trunk/jython/src/org/python/core/io/FileIO.java =================================================================== --- trunk/jython/src/org/python/core/io/FileIO.java 2010-03-21 17:52:36 UTC (rev 6987) +++ trunk/jython/src/org/python/core/io/FileIO.java 2010-03-21 21:35:14 UTC (rev 6988) @@ -65,7 +65,7 @@ File absPath = new RelativeFile(name); try { - if (appending && !reading) { + if (appending && !(reading || plus)) { // Take advantage of FileOutputStream's append mode fromFileOutputStream(absPath); } else { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |