Author: Armin Rigo <[email protected]>
Branch: 
Changeset: r56890:5584070557bf
Date: 2012-08-27 22:11 +0200
http://bitbucket.org/pypy/pypy/changeset/5584070557bf/

Log:    Copy the fix from _cffi_backend.c.

diff --git a/pypy/module/_cffi_backend/newtype.py 
b/pypy/module/_cffi_backend/newtype.py
--- a/pypy/module/_cffi_backend/newtype.py
+++ b/pypy/module/_cffi_backend/newtype.py
@@ -211,13 +211,13 @@
     if is_union:
         assert offset == 0
         offset = maxsize
-    else:
-        if offset == 0:
-            offset = 1
-        offset = (offset + alignment - 1) & ~(alignment-1)
+    offset = (offset + alignment - 1) & ~(alignment-1)
 
+    # Like C, if the size of this structure would be zero, we compute it
+    # as 1 instead.  But for ctypes support, we allow the manually-
+    # specified totalsize to be zero in this case.
     if totalsize < 0:
-        totalsize = offset
+        totalsize = offset or 1
     elif totalsize < offset:
         raise operationerrfmt(space.w_TypeError,
                      "%s cannot be of size %d: there are fields at least "
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to