[Jython-checkins] jython (merge default -> default): Merge.
frank.wierzbicki
jython-checkins at python.org
Wed Mar 21 00:48:27 CET 2012
http://hg.python.org/jython/rev/ac16e01946d8
changeset: 6446:ac16e01946d8
parent: 6445:fca881c80a21
parent: 6444:6163f0c0208f
user: Frank Wierzbicki <fwierzbicki at gmail.com>
date: Tue Mar 20 16:48:16 2012 -0700
summary:
Merge.
files:
Lib/test/test_StringIO_jy.py | 15 +++++++++++++++
NEWS | 1 +
src/org/python/modules/cStringIO.java | 6 ++++++
3 files changed, 22 insertions(+), 0 deletions(-)
diff --git a/Lib/test/test_StringIO_jy.py b/Lib/test/test_StringIO_jy.py
--- a/Lib/test/test_StringIO_jy.py
+++ b/Lib/test/test_StringIO_jy.py
@@ -28,9 +28,24 @@
f.write("uvwxyz")
self.assertEqual(f.getvalue(), 'abcdef\x00\x00\x00\x00uvwxyz')
+class TestGetValueAfterClose(unittest.TestCase):
+
+ # This test, or something like it, should be really be pushed upstream
+ def test_getvalue_after_close(self):
+ f = cStringIO.StringIO('hello')
+ f.getvalue()
+ f.close()
+ try:
+ f.getvalue()
+ except ValueError:
+ pass
+ else:
+ self.fail("cStringIO.StringIO: getvalue() after close() should have raised ValueError")
+
def test_main():
test_support.run_unittest(TestUnicodeInput)
test_support.run_unittest(TestWrite)
+ test_support.run_unittest(TestGetValueAfterClose)
if __name__ == '__main__':
test_main()
diff --git a/NEWS b/NEWS
--- a/NEWS
+++ b/NEWS
@@ -5,6 +5,7 @@
Jython 2.5.3b2
Bugs Fixed
+ - [ 1640 ] cStringIO does not complain on getvalue after close
- [ 1749 ] function descriptor doesn't work in interactive console
- [ 1721 ] NPE when using JSR 223 (TestCase+Patch)
- [ 1536 ] NPE in org.python.jsr223.PyScriptEngine:187
diff --git a/src/org/python/modules/cStringIO.java b/src/org/python/modules/cStringIO.java
--- a/src/org/python/modules/cStringIO.java
+++ b/src/org/python/modules/cStringIO.java
@@ -107,6 +107,11 @@
*/
public void close() {
closed = true;
+ // No point in zeroing the buf, because it won't be reused.
+ // buf is a final variable, so can't set to null.
+ // Therefore, just leave it and let it be GC'ed when the enclosing object is GC'ed
+ // Or remove the final declaration
+ // buf = null;
}
@@ -405,6 +410,7 @@
* @return the contents of the StringIO.
*/
public synchronized PyString getvalue() {
+ _complain_ifclosed();
return new PyString(buf.toString());
}
--
Repository URL: http://hg.python.org/jython
More information about the Jython-checkins
mailing list