[pypy-commit] pypy stdlib-2.7.11: bytearray buffers don't support get_raw_address, use a buffer that does

pjenvey pypy.commits at gmail.com
Mon Mar 21 21:59:52 EDT 2016


Author: Philip Jenvey <pjenvey at underboss.org>
Branch: stdlib-2.7.11
Changeset: r83237:86aeb7d656ab
Date: 2016-03-21 18:58 -0700
http://bitbucket.org/pypy/pypy/changeset/86aeb7d656ab/

Log:	bytearray buffers don't support get_raw_address, use a buffer that
	does

diff --git a/lib-python/2.7/ctypes/test/test_bitfields.py b/lib-python/2.7/ctypes/test/test_bitfields.py
--- a/lib-python/2.7/ctypes/test/test_bitfields.py
+++ b/lib-python/2.7/ctypes/test/test_bitfields.py
@@ -271,12 +271,13 @@
             _fields_ = [("a", c_uint32, 24),
                         ("b", c_uint32, 4),
                         ("c", c_uint32, 4)]
-        b = bytearray(4)
+        import array
+        b = array.array("c", '\x00' * 4)
         x = Little.from_buffer(b)
         x.a = 0xabcdef
         x.b = 1
         x.c = 2
-        self.assertEqual(b, b'\xef\xcd\xab\x21')
+        self.assertEqual(b.tostring(), b'\xef\xcd\xab\x21')
 
     @need_symbol('c_uint32')
     def test_uint32_swap_big_endian(self):
@@ -285,12 +286,13 @@
             _fields_ = [("a", c_uint32, 24),
                         ("b", c_uint32, 4),
                         ("c", c_uint32, 4)]
-        b = bytearray(4)
+        import array
+        b = array.array("c", '\x00' * 4)
         x = Big.from_buffer(b)
         x.a = 0xabcdef
         x.b = 1
         x.c = 2
-        self.assertEqual(b, b'\xab\xcd\xef\x12')
+        self.assertEqual(b.tostring(), b'\xab\xcd\xef\x12')
 
 if __name__ == "__main__":
     unittest.main()


More information about the pypy-commit mailing list