Author: Armin Rigo <[email protected]>
Branch:
Changeset: r67548:be1986c9f303
Date: 2013-10-24 09:03 +0200
http://bitbucket.org/pypy/pypy/changeset/be1986c9f303/
Log: Test and fix
diff --git a/pypy/module/_cffi_backend/ctypeptr.py
b/pypy/module/_cffi_backend/ctypeptr.py
--- a/pypy/module/_cffi_backend/ctypeptr.py
+++ b/pypy/module/_cffi_backend/ctypeptr.py
@@ -95,14 +95,13 @@
def convert_array_from_object(self, cdata, w_ob):
space = self.space
- if self._convert_array_from_list_strategy_maybe(cdata, w_ob):
- # the fast path worked, we are done now
- return
- #
- # continue with the slow path
if (space.isinstance_w(w_ob, space.w_list) or
space.isinstance_w(w_ob, space.w_tuple)):
- self._convert_array_from_listview(cdata, w_ob)
+ #
+ if not self._convert_array_from_list_strategy_maybe(cdata, w_ob):
+ # continue with the slow path
+ self._convert_array_from_listview(cdata, w_ob)
+ #
elif (self.can_cast_anything or
(self.ctitem.is_primitive_integer and
self.ctitem.size == rffi.sizeof(lltype.Char))):
diff --git a/pypy/module/_cffi_backend/test/test_fastpath.py
b/pypy/module/_cffi_backend/test/test_fastpath.py
--- a/pypy/module/_cffi_backend/test/test_fastpath.py
+++ b/pypy/module/_cffi_backend/test/test_fastpath.py
@@ -35,6 +35,19 @@
assert buf[2] == 3.3
+class AppTest_fast_path_bug(object):
+ spaceconfig = dict(usemodules=('_cffi_backend', 'cStringIO'))
+
+ def test_bug_not_list_or_tuple(self):
+ import _cffi_backend
+ LONG = _cffi_backend.new_primitive_type('long')
+ P_LONG = _cffi_backend.new_pointer_type(LONG)
+ LONG_ARRAY_2 = _cffi_backend.new_array_type(P_LONG, 2)
+ P_LONG_ARRAY_2 = _cffi_backend.new_pointer_type(LONG_ARRAY_2)
+ LONG_ARRAY_ARRAY = _cffi_backend.new_array_type(P_LONG_ARRAY_2, None)
+ raises(TypeError, _cffi_backend.newp, LONG_ARRAY_ARRAY, [set([4, 5])])
+
+
class AppTest_fast_path_to_list(object):
spaceconfig = dict(usemodules=('_cffi_backend', 'cStringIO'))
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit