Author: Armin Rigo <[email protected]>
Branch:
Changeset: r959:8d3d149fd8c0
Date: 2012-09-22 13:17 +0200
http://bitbucket.org/cffi/cffi/changeset/8d3d149fd8c0/
Log: A bytearray doesn't work, by design. If you really want one, you
can do buffer(p)[:] = ...
diff --git a/c/test_c.py b/c/test_c.py
--- a/c/test_c.py
+++ b/c/test_c.py
@@ -2184,3 +2184,12 @@
p = newp(BSCharArray, b"fo\xff")
assert len(p) == 4
assert list(p) == [ord("f"), ord("o"), -1, 0]
+
+def test_newp_from_bytearray_doesnt_work():
+ BCharArray = new_array_type(
+ new_pointer_type(new_primitive_type("char")), None)
+ py.test.raises(TypeError, newp, BCharArray, bytearray(b"foo"))
+ p = newp(BCharArray, 4)
+ buffer(p)[:] = bytearray(b"foo\x00")
+ assert len(p) == 4
+ assert list(p) == [b"f", b"o", b"o", b"\x00"]
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit