Commits

Armin Rigo committed 1620fee

Python 3 fixes.

  • Participants
  • Parent commits 8bb2800

Comments (0)

Files changed (3)

File c/_cffi_backend.c

 #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

File testing/test_parsing.py

     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()

File testing/test_verify.py

             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