summaryrefslogtreecommitdiff
path: root/cffi/backend_ctypes.py
diff options
context:
space:
mode:
authorArmin Rigo <arigo@tunes.org>2012-08-14 14:15:53 +0200
committerArmin Rigo <arigo@tunes.org>2012-08-14 14:15:53 +0200
commit8e3ef3bfa8973768b146ffc3f24d0f3cd34c6624 (patch)
treeb2c681d669ab38a2b1984ebc2f1b6bd0c7a6a14a /cffi/backend_ctypes.py
parenta6c6f091d866f5452ec671d6268b629337b21e27 (diff)
downloadcffi-8e3ef3bfa8973768b146ffc3f24d0f3cd34c6624.tar.gz
Pass or skip the buffer tests on 3.2 too.
The buffer interface is *still* a complete mess on Python 3.
Diffstat (limited to 'cffi/backend_ctypes.py')
-rw-r--r--cffi/backend_ctypes.py10
1 files changed, 7 insertions, 3 deletions
diff --git a/cffi/backend_ctypes.py b/cffi/backend_ctypes.py
index 2310c11..db971e2 100644
--- a/cffi/backend_ctypes.py
+++ b/cffi/backend_ctypes.py
@@ -965,10 +965,14 @@ class CTypesBackend(object):
_fields_ = [('stupid', type(val))]
ptr = ctypes.cast(buf, ctypes.POINTER(Hack))
view = memoryview(ptr.contents)
+ try:
+ view = view.cast('B')
+ except AttributeError:
+ raise NotImplementedError("buffer() with ctypes backend "
+ "in Python < 3.3")
if size >= 0:
- return view.cast('B')[:size]
- else:
- return view.cast('B')
+ view = view[:size]
+ return view
# haaaaaaaaaaaack
if '__pypy__' in sys.builtin_module_names: