[Jython-checkins] jython: bytearray.extend fixed to accept only iterable arguments.

jeff.allen jython-checkins at python.org
Fri Mar 22 23:59:27 CET 2013


http://hg.python.org/jython/rev/cf6a2f673dc5
changeset:   7101:cf6a2f673dc5
user:        Jeff Allen <ja...py at farowl.co.uk>
date:        Sun Mar 17 18:45:09 2013 +0000
summary:
  bytearray.extend fixed to accept only iterable arguments.
This was revealed in test_io, test_writelines_error() where otherwise
writelines([1,2,3]) is acceptable. Test_io now down to 81 skips.

files:
  Lib/test/test_io.py                  |  2 --
  src/org/python/core/PyByteArray.java |  2 ++
  2 files changed, 2 insertions(+), 2 deletions(-)


diff --git a/Lib/test/test_io.py b/Lib/test/test_io.py
--- a/Lib/test/test_io.py
+++ b/Lib/test/test_io.py
@@ -1206,7 +1206,6 @@
         bufio.flush()
         self.assertEqual(b''.join(writer._write_stack), b'abcdef')
 
-    @unittest.skipIf(support.is_jython, "FIXME: better type checking")
     def test_writelines_error(self):
         writer = self.MockRawIO()
         bufio = self.tp(writer, 8)
@@ -2348,7 +2347,6 @@
         txt.flush()
         self.assertEqual(buf.getvalue(), b'abcdef')
 
-    @unittest.skipIf(support.is_jython, "FIXME: better type checking")
     def test_writelines_error(self):
         txt = self.TextIOWrapper(self.BytesIO())
         self.assertRaises(TypeError, txt.writelines, [1, 2, 3])
diff --git a/src/org/python/core/PyByteArray.java b/src/org/python/core/PyByteArray.java
--- a/src/org/python/core/PyByteArray.java
+++ b/src/org/python/core/PyByteArray.java
@@ -1191,6 +1191,8 @@
 
     @ExposedMethod(doc = BuiltinDocs.bytearray_extend_doc)
     final synchronized void bytearray_extend(PyObject o) {
+        // Raise TypeError if the argument is not iterable
+        o.__iter__();
         // Use the general method, assigning to the crack at the end of the array.
         // Note this deals with all legitimate PyObject types including the case o==this.
         setslice(size, size, 1, o);

-- 
Repository URL: http://hg.python.org/jython


More information about the Jython-checkins mailing list