Commits

Armin Rigo committed 2e0764b

Support "number + pointer" too, like in C

Comments (0)

Files changed (2)

c/_cffi_backend.c

     CDataObject *cd;
     CTypeDescrObject *ctptr;
 
-    if (!CData_Check(v))
-        goto not_implemented;
+    if (!CData_Check(v)) {
+        PyObject *swap;
+        assert(CData_Check(w));
+        if (sign != 1)
+            goto not_implemented;
+        swap = v;
+        v = w;
+        w = swap;
+    }
 
     i = PyNumber_AsSsize_t(w, PyExc_OverflowError);
     if (i == -1 && PyErr_Occurred())
     assert repr(a) == "<cdata 'int[3][5]' owning %d bytes>" % (
         3*5*size_of_int(),)
     assert repr(a + 0).startswith("<cdata 'int(*)[5]' 0x")
+    assert 0 + a == a + 0 != 1 + a == a + 1
     assert repr(a[0]).startswith("<cdata 'int[5]' 0x")
     assert repr((a + 0)[0]).startswith("<cdata 'int[5]' 0x")
     assert repr(a[0] + 0).startswith("<cdata 'int *' 0x")