HCT added the comment:

more examples (using 64-bit integer vs 8-bit integer in the above example) to 
show that ctypes aren't being translated for memoryview properly. _pack_ is the 
only way to make memoryview handle ctypes properly


>>> import ctypes
>>> class B1(ctypes.Structure):
...     _fields_ = [( "data", ctypes.c_uint64 * 256 ), ]
...     _pack_ = 1
...
>>> class B2(ctypes.Structure):
...     _fields_ = [( "data", ctypes.c_uint64 * 256 ), ]
...
>>>
>>> a = B1()
>>> b = B2()
>>> memoryview( a ).cast( 'B' )
<memory at 0x01FFB030>
>>> memoryview( b ).cast( 'B' )
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ValueError: memoryview: source format must be a native single character format 
prefixed with an optional '@'
>>>

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue19803>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to