[New-bugs-announce] [issue15857] memoryview of a ctypes struct has incompatible invalid format

Alexander Belopolsky report at bugs.python.org
Mon Sep 3 18:24:57 CEST 2012


New submission from Alexander Belopolsky:

Starting with the example in memoryview documentation:

>>> from ctypes import BigEndianStructure, c_long
>>> class BEPoint(BigEndianStructure):
...     _fields_ = [("x", c_long), ("y", c_long)]
...
>>> point = BEPoint(100, 200)
>>> a = memoryview(point)

I am trying to unpack the resulting view:

>>> a.tolist()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NotImplementedError: memoryview: unsupported format T{>l:x:>l:y:}

>>> struct.unpack_from(a.format,a)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
struct.error: bad char in struct format

>>> struct.unpack_from('>ll',a)
(0, 100)


It looks like there is one or more bugs in play here.

----------
messages: 169771
nosy: belopolsky, skrah
priority: normal
severity: normal
status: open
title: memoryview of a ctypes struct has incompatible invalid format
type: behavior
versions: Python 3.3, Python 3.4

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue15857>
_______________________________________


More information about the New-bugs-announce mailing list