Author: Armin Rigo <[email protected]>
Branch:
Changeset: r2661:6e5dfaf706ba
Date: 2016-04-15 19:36 +0200
http://bitbucket.org/cffi/cffi/changeset/6e5dfaf706ba/
Log: Python3 compat
diff --git a/c/test_c.py b/c/test_c.py
--- a/c/test_c.py
+++ b/c/test_c.py
@@ -3529,9 +3529,9 @@
def test_rawstring():
BChar = new_primitive_type("char")
BArray = new_array_type(new_pointer_type(BChar), 10) # char[10]
- p = newp(BArray, "abc\x00def")
- assert rawstring(p) == "abc\x00def\x00\x00\x00"
- assert rawstring(p[1:6]) == "bc\x00de"
+ p = newp(BArray, b"abc\x00def")
+ assert rawstring(p) == b"abc\x00def\x00\x00\x00"
+ assert rawstring(p[1:6]) == b"bc\x00de"
BWChar = new_primitive_type("wchar_t")
BArray = new_array_type(new_pointer_type(BWChar), 10) # wchar_t[10]
p = newp(BArray, u"abc\x00def")
@@ -3540,7 +3540,7 @@
BChar = new_primitive_type("uint8_t")
BArray = new_array_type(new_pointer_type(BChar), 10) # uint8_t[10]
p = newp(BArray, [65 + i for i in range(10)])
- assert rawstring(p) == "ABCDEFGHIJ"
+ assert rawstring(p) == b"ABCDEFGHIJ"
#
py.test.raises(TypeError, rawstring, "foobar")
py.test.raises(TypeError, rawstring, p + 1)
diff --git a/testing/cffi0/test_ffi_backend.py
b/testing/cffi0/test_ffi_backend.py
--- a/testing/cffi0/test_ffi_backend.py
+++ b/testing/cffi0/test_ffi_backend.py
@@ -475,9 +475,9 @@
def test_rawstring(self):
ffi = FFI()
- p = ffi.new("char[]", "abc\x00def")
- assert ffi.rawstring(p) == "abc\x00def\x00"
- assert ffi.rawstring(p[1:6]) == "bc\x00de"
+ p = ffi.new("char[]", b"abc\x00def")
+ assert ffi.rawstring(p) == b"abc\x00def\x00"
+ assert ffi.rawstring(p[1:6]) == b"bc\x00de"
p = ffi.new("wchar_t[]", u"abc\x00def")
assert ffi.rawstring(p) == u"abc\x00def\x00"
assert ffi.rawstring(p[1:6]) == u"bc\x00de"
diff --git a/testing/cffi1/test_ffi_obj.py b/testing/cffi1/test_ffi_obj.py
--- a/testing/cffi1/test_ffi_obj.py
+++ b/testing/cffi1/test_ffi_obj.py
@@ -498,9 +498,9 @@
def test_rawstring():
ffi = _cffi1_backend.FFI()
- p = ffi.new("char[]", "abc\x00def")
- assert ffi.rawstring(p) == "abc\x00def\x00"
- assert ffi.rawstring(p[1:6]) == "bc\x00de"
+ p = ffi.new("char[]", b"abc\x00def")
+ assert ffi.rawstring(p) == b"abc\x00def\x00"
+ assert ffi.rawstring(p[1:6]) == b"bc\x00de"
p = ffi.new("wchar_t[]", u"abc\x00def")
assert ffi.rawstring(p) == u"abc\x00def\x00"
assert ffi.rawstring(p[1:6]) == u"bc\x00de"
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit