[pypy-commit] pypy remove-list-smm-2: Test and fix for comparisons of list and non-lists.

Manuel Jacob noreply at buildbot.pypy.org
Sat May 18 12:05:41 CEST 2013


Author: Manuel Jacob
Branch: remove-list-smm-2
Changeset: r64276:14e9e505be43
Date: 2013-05-18 12:03 +0200
http://bitbucket.org/pypy/pypy/changeset/14e9e505be43/

Log:	Test and fix for comparisons of list and non-lists.

diff --git a/pypy/objspace/std/listobject.py b/pypy/objspace/std/listobject.py
--- a/pypy/objspace/std/listobject.py
+++ b/pypy/objspace/std/listobject.py
@@ -3,6 +3,7 @@
 from pypy.objspace.std.inttype import wrapint
 from pypy.objspace.std.sliceobject import W_SliceObject, normalize_simple_slice
 from pypy.objspace.std import slicetype
+from pypy.objspace.std.util import negate
 from pypy.interpreter.gateway import WrappedDefault, unwrap_spec, applevel,\
      interp2app
 from pypy.interpreter import baseobjspace
@@ -375,8 +376,7 @@
             i += 1
         return space.w_True
 
-    def descr_ne(self, space, w_other):
-        return space.not_(self.descr_eq(space, w_other))
+    descr_ne = negate(descr_eq)
 
     def _make_list_comparison(name):
         import operator
diff --git a/pypy/objspace/std/test/test_listobject.py b/pypy/objspace/std/test/test_listobject.py
--- a/pypy/objspace/std/test/test_listobject.py
+++ b/pypy/objspace/std/test/test_listobject.py
@@ -1308,6 +1308,12 @@
     def test_use_method_for_wrong_object(self):
         raises(TypeError, list.append.im_func, 1, 2)
 
+    def test_ne_NotImplemented(self):
+        class NonList(object):
+            pass
+        non_list = NonList()
+        assert [] != non_list
+
 
 class AppTestForRangeLists(AppTestW_ListObject):
     spaceconfig = {"objspace.std.withrangelist": True}


More information about the pypy-commit mailing list