New submission from HCT: I'm trying to create ctypes buffer to be used back and forth with C libraries, but I keep getting errors. I need to slice the buffer to cut out different pieces to work on, so I try to get a memoryview of the buffer. does the error message imply that c_ubyte, c_uint8, c_byte and c_char are not native single character types?
>>> memoryview(c_ubyte()).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 '@' >>> memoryview((c_ubyte*1024)()).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 '@' >>> memoryview(c_uint8()).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 '@' >>> memoryview((c_uint8*1024)()).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 '@' >>> memoryview((c_byte*1024)()).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 '@' >>> memoryview((c_char*1024)()).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 '@' >>> memoryview((c_char*1024)())[0] Traceback (most recent call last): File "<stdin>", line 1, in <module> NotImplementedError: memoryview: unsupported format (1024)<c >>> memoryview((c_byte*1024)())[0] Traceback (most recent call last): File "<stdin>", line 1, in <module> NotImplementedError: memoryview: unsupported format (1024)<b >>> memoryview((c_ubyte*1024)())[0] Traceback (most recent call last): File "<stdin>", line 1, in <module> NotImplementedError: memoryview: unsupported format (1024)<B >>> memoryview((c_uint8*1024)())[0] Traceback (most recent call last): File "<stdin>", line 1, in <module> NotImplementedError: memoryview: unsupported format (1024)<B >>> ---------- components: Library (Lib), ctypes messages: 204536 nosy: hct priority: normal severity: normal status: open title: memoryview complain ctypes byte array are not native single character versions: Python 3.3 _______________________________________ 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