[pypy-commit] pypy py3.3: omit sorting the items in dir/type/module __dir__, like cpython does

numerodix noreply at buildbot.pypy.org
Sat Aug 2 00:40:05 CEST 2014


Author: Martin Matusiak <numerodix at gmail.com>
Branch: py3.3
Changeset: r72646:743d934f01f7
Date: 2014-08-01 21:16 +0200
http://bitbucket.org/pypy/pypy/changeset/743d934f01f7/

Log:	omit sorting the items in dir/type/module __dir__, like cpython does

diff --git a/pypy/interpreter/module.py b/pypy/interpreter/module.py
--- a/pypy/interpreter/module.py
+++ b/pypy/interpreter/module.py
@@ -129,7 +129,6 @@
             w__dict__ = space.getattr(self, space.wrap('__dict__'))
             result = space.listview(w__dict__)
             w_result = space.wrap(result)
-            space.call_method(w_result, 'sort')
             return w_result
         except OperationError as e:
             if e.match(space, space.w_AttributeError):
diff --git a/pypy/interpreter/test/test_module.py b/pypy/interpreter/test/test_module.py
--- a/pypy/interpreter/test/test_module.py
+++ b/pypy/interpreter/test/test_module.py
@@ -71,8 +71,7 @@
     def test_dir(self):
         import sys
         items = sys.__dir__()
-        assert items == sorted(items)
-        assert items == dir(sys)
+        assert sorted(items) == dir(sys)
 
     def test_package(self):
         import sys
diff --git a/pypy/objspace/std/objecttype.py b/pypy/objspace/std/objecttype.py
--- a/pypy/objspace/std/objecttype.py
+++ b/pypy/objspace/std/objecttype.py
@@ -49,7 +49,6 @@
         except AttributeError:
             pass
         result = list(Dict.keys())
-        result.sort()
         return result
     """)
     return w_result
diff --git a/pypy/objspace/std/test/test_obj.py b/pypy/objspace/std/test/test_obj.py
--- a/pypy/objspace/std/test/test_obj.py
+++ b/pypy/objspace/std/test/test_obj.py
@@ -113,7 +113,7 @@
         obj = A()
         obj_items = dir(obj)
         assert obj_items == sorted(obj_items)
-        assert obj_items == dir(obj)
+        assert obj_items == sorted(object.__dir__(obj))
 
 
     def test_is_on_primitives(self):
diff --git a/pypy/objspace/std/test/test_typeobject.py b/pypy/objspace/std/test/test_typeobject.py
--- a/pypy/objspace/std/test/test_typeobject.py
+++ b/pypy/objspace/std/test/test_typeobject.py
@@ -728,7 +728,6 @@
                 pass
 
         C_items = dir(C)
-        assert C_items == sorted(C_items)
         assert C_items != C.__dir__(C)  # as in cpython
 
         assert 'a_var' in C_items
diff --git a/pypy/objspace/std/typeobject.py b/pypy/objspace/std/typeobject.py
--- a/pypy/objspace/std/typeobject.py
+++ b/pypy/objspace/std/typeobject.py
@@ -750,7 +750,6 @@
             return Dict
 
         result = list(_classdir(obj).keys())
-        result.sort()
         return result
     """)
     return w_result


More information about the pypy-commit mailing list