Paul Moore wrote:
> One of the failures here is in
>
> def test_create_from_bytes(self):
> a = array.array('H', b"1234")
> self.assertEqual(len(a) * a.itemsize, 4)
>
> Traceback (most recent call last):
> File "Lib/test/test_array.py", line 737, in test_create_from_bytes
> self.assertEqual(len(a) * a.itemsize, 4)
> AssertionError: 8 != 4
>
> However, 'H' is unsigned short, so I'd expect a.itemsize to be 2, and
> so the results *should* be 8 rather than 4.
>
> Is this just a bug in the test?
No, it was a bug in the C code. 'H' represents a 16bit type. The correct
result is
>>> array.array('H', b"1234")
array('H', [12849, 13363])
However the code was reading the byte sequence int by int and created an
array with 4 elements instead of 2 elements. I've already fixed it.
Christian
_______________________________________________
Python-3000 mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-3000
Unsubscribe:
http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com