Author: Ronan Lamy <[email protected]>
Branch: PyBuffer
Changeset: r91147:65cc783b56e6
Date: 2017-04-28 20:29 +0100
http://bitbucket.org/pypy/pypy/changeset/65cc783b56e6/

Log:    'fix' test by documenting a difference with CPython

diff --git a/pypy/module/array/interp_array.py 
b/pypy/module/array/interp_array.py
--- a/pypy/module/array/interp_array.py
+++ b/pypy/module/array/interp_array.py
@@ -403,6 +403,8 @@
         machine values, as if it had been read from a file using the
         fromfile() method).
         """
+        # For some reason, CPython rejects arguments with itemsize != 1 here
+        # (like array.array('i')). We don't apply that restriction.
         s = space.charbuf_w(w_s)
         self._frombytes(space, s)
 
diff --git a/pypy/module/array/test/test_array.py 
b/pypy/module/array/test/test_array.py
--- a/pypy/module/array/test/test_array.py
+++ b/pypy/module/array/test/test_array.py
@@ -170,6 +170,7 @@
             assert len(b) == 2 and b[0] == 0 and b[1] == 0
 
     def test_frombytes(self):
+        import sys
         for t in 'bBhHiIlLfd':
             a = self.array(t)
             a.frombytes(b'\x00' * a.itemsize * 2)
@@ -199,7 +200,12 @@
                     # bad I suppose.
                     assert a.tolist() == old_items * 2
             else:
-                raises(TypeError, a.frombytes, a)
+                if '__pypy__' in sys.modules:
+                    old_items = a.tolist()
+                    a.frombytes(a)
+                    assert a.tolist() == old_items * 2
+                else:
+                    raises(TypeError, a.frombytes, a)
 
     def test_fromfile(self):
         def myfile(c, s):
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to