Author: Armin Rigo <ar...@tunes.org> Branch: Changeset: r53113:18eccde6f1a4 Date: 2012-03-02 16:00 +0100 http://bitbucket.org/pypy/pypy/changeset/18eccde6f1a4/
Log: Test and fix. diff --git a/pypy/module/array/interp_array.py b/pypy/module/array/interp_array.py --- a/pypy/module/array/interp_array.py +++ b/pypy/module/array/interp_array.py @@ -160,13 +160,15 @@ def make_array(mytype): + W_ArrayBase = globals()['W_ArrayBase'] + class W_Array(W_ArrayBase): itemsize = mytype.bytes typecode = mytype.typecode @staticmethod def register(typeorder): - typeorder[W_Array] = [] + typeorder[W_Array] = [(W_ArrayBase, None)] def __init__(self, space): self.space = space @@ -586,29 +588,26 @@ # Compare methods @specialize.arg(3) def _cmp_impl(space, self, other, space_fn): - if isinstance(other, W_ArrayBase): - w_lst1 = array_tolist__Array(space, self) - w_lst2 = space.call_method(other, 'tolist') - return space_fn(w_lst1, w_lst2) - else: - return space.w_NotImplemented + w_lst1 = array_tolist__Array(space, self) + w_lst2 = space.call_method(other, 'tolist') + return space_fn(w_lst1, w_lst2) - def eq__Array_ANY(space, self, other): + def eq__Array_ArrayBase(space, self, other): return _cmp_impl(space, self, other, space.eq) - def ne__Array_ANY(space, self, other): + def ne__Array_ArrayBase(space, self, other): return _cmp_impl(space, self, other, space.ne) - def lt__Array_ANY(space, self, other): + def lt__Array_ArrayBase(space, self, other): return _cmp_impl(space, self, other, space.lt) - def le__Array_ANY(space, self, other): + def le__Array_ArrayBase(space, self, other): return _cmp_impl(space, self, other, space.le) - def gt__Array_ANY(space, self, other): + def gt__Array_ArrayBase(space, self, other): return _cmp_impl(space, self, other, space.gt) - def ge__Array_ANY(space, self, other): + def ge__Array_ArrayBase(space, self, other): return _cmp_impl(space, self, other, space.ge) # Misc methods diff --git a/pypy/module/array/test/test_array.py b/pypy/module/array/test/test_array.py --- a/pypy/module/array/test/test_array.py +++ b/pypy/module/array/test/test_array.py @@ -845,8 +845,11 @@ cls.maxint = sys.maxint class AppTestArray(BaseArrayTests): + OPTIONS = {} + def setup_class(cls): - cls.space = gettestobjspace(usemodules=('array', 'struct', '_rawffi')) + cls.space = gettestobjspace(usemodules=('array', 'struct', '_rawffi'), + **cls.OPTIONS) cls.w_array = cls.space.appexec([], """(): import array return array.array @@ -868,3 +871,7 @@ a = self.array('b', range(4)) a[::-1] = a assert a == self.array('b', [3, 2, 1, 0]) + + +class AppTestArrayBuiltinShortcut(AppTestArray): + OPTIONS = {'objspace.std.builtinshortcut': True} _______________________________________________ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit