Author: Armin Rigo <[email protected]>
Branch: 
Changeset: r77705:948b7cb6e6e3
Date: 2015-05-30 14:02 +0200
http://bitbucket.org/pypy/pypy/changeset/948b7cb6e6e3/

Log:    import cffi/a0a5812b5d41

diff --git a/lib_pypy/cffi/_cffi_include.h b/lib_pypy/cffi/_cffi_include.h
--- a/lib_pypy/cffi/_cffi_include.h
+++ b/lib_pypy/cffi/_cffi_include.h
@@ -212,7 +212,7 @@
      (size) == 2 ? ((sign) ? _CFFI_PRIM_INT16 : _CFFI_PRIM_UINT16) :    \
      (size) == 4 ? ((sign) ? _CFFI_PRIM_INT32 : _CFFI_PRIM_UINT32) :    \
      (size) == 8 ? ((sign) ? _CFFI_PRIM_INT64 : _CFFI_PRIM_UINT64) :    \
-     0)
+     _CFFI__UNKNOWN_PRIM)
 
 #define _cffi_check_int(got, got_nonpos, expected)      \
     ((got_nonpos) == (expected <= 0) &&                 \
diff --git a/lib_pypy/cffi/cffi_opcode.py b/lib_pypy/cffi/cffi_opcode.py
--- a/lib_pypy/cffi/cffi_opcode.py
+++ b/lib_pypy/cffi/cffi_opcode.py
@@ -12,13 +12,13 @@
         return '_CFFI_OP(_CFFI_OP_%s, %s)' % (classname, self.arg)
 
     def as_python_bytes(self):
-        if self.op is None:
-            if self.arg.isdigit():
-                value = int(self.arg)     # non-negative: '-' not in self.arg
-                if value >= 2**31:
-                    raise OverflowError("cannot emit %r: limited to 2**31-1"
-                                        % (self.arg,))
-                return format_four_bytes(value)
+        if self.op is None and self.arg.isdigit():
+            value = int(self.arg)     # non-negative: '-' not in self.arg
+            if value >= 2**31:
+                raise OverflowError("cannot emit %r: limited to 2**31-1"
+                                    % (self.arg,))
+            return format_four_bytes(value)
+        if isinstance(self.arg, str):
             from .ffiplatform import VerificationError
             raise VerificationError("cannot emit to Python: %r" % (self.arg,))
         return format_four_bytes((self.arg << 8) | self.op)
@@ -105,6 +105,7 @@
 PRIM_UINTMAX       = 47
 
 _NUM_PRIM          = 48
+_UNKNOWN_PRIM      = -1
 
 PRIMITIVE_TO_INDEX = {
     'char':               PRIM_CHAR,
diff --git a/lib_pypy/cffi/parse_c_type.h b/lib_pypy/cffi/parse_c_type.h
--- a/lib_pypy/cffi/parse_c_type.h
+++ b/lib_pypy/cffi/parse_c_type.h
@@ -78,6 +78,7 @@
 #define _CFFI_PRIM_UINTMAX      47
 
 #define _CFFI__NUM_PRIM         48
+#define _CFFI__UNKNOWN_PRIM    (-1)
 
 
 struct _cffi_global_s {
diff --git a/pypy/module/test_lib_pypy/cffi_tests/cffi1/test_recompiler.py 
b/pypy/module/test_lib_pypy/cffi_tests/cffi1/test_recompiler.py
--- a/pypy/module/test_lib_pypy/cffi_tests/cffi1/test_recompiler.py
+++ b/pypy/module/test_lib_pypy/cffi_tests/cffi1/test_recompiler.py
@@ -875,9 +875,11 @@
     """)
     # can't read or write it at all
     e = py.test.raises(TypeError, getattr, lib, 'globvar')
-    assert str(e.value) == "cdata 'opaque_t' is opaque"
+    assert str(e.value) in ["cdata 'opaque_t' is opaque",
+                            "'opaque_t' is opaque or not completed yet"] #pypy
     e = py.test.raises(TypeError, setattr, lib, 'globvar', [])
-    assert str(e.value) == "'opaque_t' is opaque"
+    assert str(e.value) in ["'opaque_t' is opaque",
+                            "'opaque_t' is opaque or not completed yet"] #pypy
     # but we can get its address
     p = ffi.addressof(lib, 'globvar')
     assert ffi.typeof(p) == ffi.typeof('opaque_t *')
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to