[pypy-commit] pypy default: Copy the fix from _cffi_backend.c.
arigo
noreply at buildbot.pypy.org
Mon Aug 27 22:11:43 CEST 2012
Author: Armin Rigo <arigo at tunes.org>
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 "
More information about the pypy-commit
mailing list