[pypy-commit] pypy default: next test
arigo
noreply at buildbot.pypy.org
Tue Jan 27 19:51:27 CET 2015
Author: Armin Rigo <arigo at tunes.org>
Branch:
Changeset: r75551:fd84f7bb7315
Date: 2015-01-27 19:51 +0100
http://bitbucket.org/pypy/pypy/changeset/fd84f7bb7315/
Log: next test
diff --git a/lib-python/2.7/ctypes/test/test_frombuffer.py b/lib-python/2.7/ctypes/test/test_frombuffer.py
--- a/lib-python/2.7/ctypes/test/test_frombuffer.py
+++ b/lib-python/2.7/ctypes/test/test_frombuffer.py
@@ -36,7 +36,6 @@
self.assertRaises((TypeError, ValueError),
(c_char * 16).from_buffer, "a" * 16)
- @xfail
def test_fom_buffer_with_offset(self):
a = array.array("i", range(16))
x = (c_int * 15).from_buffer(a, sizeof(c_int))
diff --git a/lib_pypy/_ctypes/basics.py b/lib_pypy/_ctypes/basics.py
--- a/lib_pypy/_ctypes/basics.py
+++ b/lib_pypy/_ctypes/basics.py
@@ -85,7 +85,12 @@
def from_buffer(self, obj, offset=0):
# XXX missing size checks
- raw_addr = buffer(obj, offset)._pypy_raw_address()
+ buf = buffer(obj, offset)
+ if len(buf) < self._sizeofinstances():
+ raise ValueError(
+ "Buffer size too small (%d instead of at least %d bytes)"
+ % (len(buffer(obj)), self._sizeofinstances() + offset))
+ raw_addr = buf._pypy_raw_address()
result = self.from_address(raw_addr)
result._ensure_objects()['ffffffff'] = obj
return result
More information about the pypy-commit
mailing list