Author: Matti Picus <[email protected]>
Branch: py3.6
Changeset: r96442:58997e887cf5
Date: 2019-04-11 09:54 +0300
http://bitbucket.org/pypy/pypy/changeset/58997e887cf5/
Log: fix memoryview(ctype_struct) for padding, fixes cpython bpo-32780
diff --git a/lib_pypy/_ctypes/array.py b/lib_pypy/_ctypes/array.py
--- a/lib_pypy/_ctypes/array.py
+++ b/lib_pypy/_ctypes/array.py
@@ -296,7 +296,11 @@
else:
bo = byteorder[sys.byteorder]
flds = []
+ cum_size = 0
for name, obj in typ._fields_:
+ padding = typ._ffistruct_.fieldoffset(name) - cum_size
+ if padding:
+ flds.append('%dx' % padding)
# Trim off the leading '<' or '>'
ch = get_format_str(obj)[1:]
if (ch) == 'B':
@@ -307,6 +311,7 @@
flds.append(':')
flds.append(name)
flds.append(':')
+ cum_size += typ._ffistruct_.fieldsize(name)
return 'T{' + ''.join(flds) + '}'
elif hasattr(typ, '_type_'):
ch = typ._type_
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit