Author: Armin Rigo <[email protected]>
Branch:
Changeset: r1299:bc462d3c35a6
Date: 2013-07-30 18:44 +0200
http://bitbucket.org/cffi/cffi/changeset/bc462d3c35a6/
Log: Crash with a clear error message in case of built-in but unsupported
types. Add a test that fails so far, to fix.
diff --git a/cffi/commontypes.py b/cffi/commontypes.py
--- a/cffi/commontypes.py
+++ b/cffi/commontypes.py
@@ -30,7 +30,9 @@
elif result in model.PrimitiveType.ALL_PRIMITIVE_TYPES:
result = model.PrimitiveType(result)
else:
- assert commontype != result
+ if commontype == result:
+ raise api.FFIError("Unsupported type: %r. Please file a bug "
+ "if you think it should be." %
(commontype,))
result = resolve_common_type(result) # recursively
assert isinstance(result, model.BaseTypeByIdentity)
_CACHE[commontype] = result
diff --git a/testing/backend_tests.py b/testing/backend_tests.py
--- a/testing/backend_tests.py
+++ b/testing/backend_tests.py
@@ -198,6 +198,9 @@
typerepr = self.TypeRepr
ffi = FFI(backend=self.Backend())
ffi.cdef("struct foo { short a, b, c; };")
+ p = ffi.cast("short unsigned int", 0)
+ assert repr(p) == "<cdata 'unsigned short' 0>"
+ assert repr(ffi.typeof(p)) == typerepr % "unsigned short"
p = ffi.cast("unsigned short int", 0)
assert repr(p) == "<cdata 'unsigned short' 0>"
assert repr(ffi.typeof(p)) == typerepr % "unsigned short"
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit