[Jython-checkins] jython: In file.writelines(), notice if an iterable argument closes the file.
jeff.allen
jython-checkins at python.org
Sat Nov 30 17:52:52 CET 2013
http://hg.python.org/jython/rev/3994804235da
changeset: 7161:3994804235da
user: Jeff Allen <ja.py at farowl.co.uk>
date: Mon Nov 25 22:11:29 2013 +0000
summary:
In file.writelines(), notice if an iterable argument closes the file.
Resolves test_file2k failure in testNastyWritelinesGenerator.
files:
Lib/test/test_file2k.py | 1 -
src/org/python/core/PyFile.java | 1 +
2 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/Lib/test/test_file2k.py b/Lib/test/test_file2k.py
--- a/Lib/test/test_file2k.py
+++ b/Lib/test/test_file2k.py
@@ -148,7 +148,6 @@
def testReadWhenWriting(self):
self.assertRaises(IOError, self.f.read)
- @unittest.skipIf(test_support.is_jython, "FIXME: Not working on Jython")
def testNastyWritelinesGenerator(self):
def nasty():
for i in range(5):
diff --git a/src/org/python/core/PyFile.java b/src/org/python/core/PyFile.java
--- a/src/org/python/core/PyFile.java
+++ b/src/org/python/core/PyFile.java
@@ -425,6 +425,7 @@
checkClosed();
PyObject iter = Py.iter(lines, "writelines() requires an iterable argument");
for (PyObject item = null; (item = iter.__iternext__()) != null;) {
+ checkClosed(); // ... in case a nasty iterable closed this file
softspace = false;
file.write(asWritable(item, "writelines() argument must be a sequence of strings"));
}
--
Repository URL: http://hg.python.org/jython
More information about the Jython-checkins
mailing list