1. jython
  2. jython

Commits

Frank Wierzbicki  committed 98a58fb

#1862 cStringIO now takes array arguments. Thanks Santoso Wijaya!

  • Participants
  • Parent commits e8b0f39
  • Branches default

Comments (0)

Files changed (3)

File Lib/test/test_StringIO.py

View file
 class TestcStringIO(TestGenericStringIO):
     MODULE = cStringIO
 
-    @unittest.skipIf(test_support.is_jython, "FIXME #1862: not working in Jython")
     def test_array_support(self):
         # Issue #1730114: cStringIO should accept array objects
         a = array.array('B', [0,1,2])

File NEWS

View file
 
 Jython 2.7b2
   Bugs Fixed
+    - [ 1862 ] cStringIO does not support arrays as arguments
     - [ 2027 ] Discrepancy in bin(-num) output
     - [ 2005 ] threading.Event object's wait([timeout]) function returns null instead of True/False.
     - [ 1926 ] Adjust MutableSet.pop test so we do not need to skip it

File src/org/python/modules/cStringIO.java

View file
 package org.python.modules;
 
 import org.python.core.Py;
+import org.python.core.PyArray;
 import org.python.core.PyIterator;
 import org.python.core.PyList;
 import org.python.core.PyObject;
         return new StringIO(buffer);
     }
 
+    /**
+     * Create a StringIO object, initialized by an array's byte stream.
+     * @param array       The initial value, from an array.
+     * @return          a new StringIO object.
+     */
+    public static StringIO StringIO(PyArray array) {
+        return new StringIO(array);
+    }
+
 
     /**
      * The StringIO object
             buf = new StringBuilder(buffer);
         }
 
+        public StringIO(PyArray array) {
+            buf = new StringBuilder(array.tostring());
+        }
+
         private void _complain_ifclosed() {
             if (closed)
                 throw Py.ValueError("I/O operation on closed file");