[pypy-commit] pypy default: update to cffi/be44fd9b3554
arigo
noreply at buildbot.pypy.org
Sat Nov 14 09:08:29 EST 2015
Author: Armin Rigo <arigo at tunes.org>
Branch:
Changeset: r80674:a0c84a4e59b6
Date: 2015-11-14 15:08 +0100
http://bitbucket.org/pypy/pypy/changeset/a0c84a4e59b6/
Log: update to cffi/be44fd9b3554
diff --git a/lib_pypy/cffi/model.py b/lib_pypy/cffi/model.py
--- a/lib_pypy/cffi/model.py
+++ b/lib_pypy/cffi/model.py
@@ -514,12 +514,17 @@
if self.baseinttype is not None:
return self.baseinttype.get_cached_btype(ffi, finishlist)
#
+ from . import api
if self.enumvalues:
smallest_value = min(self.enumvalues)
largest_value = max(self.enumvalues)
else:
- smallest_value = 0
- largest_value = 0
+ import warnings
+ warnings.warn("%r has no values explicitly defined; next version "
+ "will refuse to guess which integer type it is "
+ "meant to be (unsigned/signed, int/long)"
+ % self._get_c_name())
+ smallest_value = largest_value = 0
if smallest_value < 0: # needs a signed type
sign = 1
candidate1 = PrimitiveType("int")
diff --git a/pypy/module/test_lib_pypy/cffi_tests/cffi0/backend_tests.py b/pypy/module/test_lib_pypy/cffi_tests/cffi0/backend_tests.py
--- a/pypy/module/test_lib_pypy/cffi_tests/cffi0/backend_tests.py
+++ b/pypy/module/test_lib_pypy/cffi_tests/cffi0/backend_tests.py
@@ -1336,7 +1336,8 @@
# these depend on user-defined data, so should not be shared
assert ffi1.typeof("struct foo") is not ffi2.typeof("struct foo")
assert ffi1.typeof("union foo *") is not ffi2.typeof("union foo*")
- assert ffi1.typeof("enum foo") is not ffi2.typeof("enum foo")
+ # the following test is an opaque enum, which we no longer support
+ #assert ffi1.typeof("enum foo") is not ffi2.typeof("enum foo")
# sanity check: twice 'ffi1'
assert ffi1.typeof("struct foo*") is ffi1.typeof("struct foo *")
@@ -1348,6 +1349,17 @@
assert ffi.getctype("pe") == 'e *'
assert ffi.getctype("e1*") == 'e1 *'
+ def test_opaque_enum(self):
+ ffi = FFI(backend=self.Backend())
+ ffi.cdef("enum foo;")
+ from cffi import __version_info__
+ if __version_info__ < (1, 4):
+ py.test.skip("re-enable me in version 1.4")
+ e = py.test.raises(CDefError, ffi.cast, "enum foo", -1)
+ assert str(e.value) == (
+ "'enum foo' has no values explicitly defined: refusing to guess "
+ "which integer type it is meant to be (unsigned/signed, int/long)")
+
def test_new_ctype(self):
ffi = FFI(backend=self.Backend())
p = ffi.new("int *")
More information about the pypy-commit
mailing list