[pypy-commit] cffi default: Python 3 fixes.

arigo noreply at buildbot.pypy.org
Thu Feb 28 16:16:46 CET 2013


Author: Armin Rigo <arigo at tunes.org>
Branch: 
Changeset: r1175:1620fee43bde
Date: 2013-02-28 16:14 +0100
http://bitbucket.org/cffi/cffi/changeset/1620fee43bde/

Log:	Python 3 fixes.

diff --git a/c/_cffi_backend.c b/c/_cffi_backend.c
--- a/c/_cffi_backend.c
+++ b/c/_cffi_backend.c
@@ -54,6 +54,7 @@
 #if PY_MAJOR_VERSION >= 3
 # define PyInt_FromLong PyLong_FromLong
 # define PyInt_FromSsize_t PyLong_FromSsize_t
+# define PyInt_AsSsize_t PyLong_AsSsize_t
 #endif
 
 #if PY_MAJOR_VERSION >= 3
diff --git a/testing/test_parsing.py b/testing/test_parsing.py
--- a/testing/test_parsing.py
+++ b/testing/test_parsing.py
@@ -210,11 +210,12 @@
     assert str(e.value).startswith('cannot parse "int(*)(foobarbazunknown)"')
 
 def test_redefine_common_type():
+    prefix = "" if sys.version_info < (3,) else "b"
     ffi = FFI()
     ffi.cdef("typedef char FILE;")
-    assert repr(ffi.cast("FILE", 123)) == "<cdata 'char' '{'>"
+    assert repr(ffi.cast("FILE", 123)) == "<cdata 'char' %s'{'>" % prefix
     ffi.cdef("typedef char int32_t;")
-    assert repr(ffi.cast("int32_t", 123)) == "<cdata 'char' '{'>"
+    assert repr(ffi.cast("int32_t", 123)) == "<cdata 'char' %s'{'>" % prefix
 
 def test_bool():
     ffi = FFI()
diff --git a/testing/test_verify.py b/testing/test_verify.py
--- a/testing/test_verify.py
+++ b/testing/test_verify.py
@@ -1563,7 +1563,7 @@
             return (x == NULL);
         }
     """)
-    assert lib.seeme1("foo") == 0
+    assert lib.seeme1(b"foo") == 0
     assert lib.seeme1(None) == 1
     assert lib.seeme2([42, 43]) == 0
     assert lib.seeme2(None) == 1


More information about the pypy-commit mailing list