Browse Source

Port lru_cache.py to python 3

Gary van der Merwe 10 years ago
parent
commit
bb6071d180
2 changed files with 6 additions and 7 deletions
  1. 6 1
      dulwich/lru_cache.py
  2. 0 6
      dulwich/tests/test_lru_cache.py

+ 6 - 1
dulwich/lru_cache.py

@@ -17,8 +17,13 @@
 
 """A simple least-recently-used (LRU) cache."""
 
+from dulwich._py3_compat import (
+    items,
+)
+
 _null_key = object()
 
+
 class _LRUNode(object):
     """This maintains the linked-list which is the lru internals."""
 
@@ -181,7 +186,7 @@ class LRUCache(object):
 
     def items(self):
         """Get the key:value pairs as a dict."""
-        return dict((k, n.value) for k, n in self._cache.iteritems())
+        return dict((k, n.value) for k, n in items(self._cache))
 
     def cleanup(self):
         """Clear the cache until it shrinks to the requested size.

+ 0 - 6
dulwich/tests/test_lru_cache.py

@@ -22,12 +22,7 @@ from dulwich import (
 from dulwich.tests import (
     TestCase,
     )
-from dulwich.tests.utils import (
-    skipIfPY3,
-    )
-
 
-@skipIfPY3
 class TestLRUCache(TestCase):
     """Test that LRU cache properly keeps track of entries."""
 
@@ -291,7 +286,6 @@ class TestLRUCache(TestCase):
         self.assertEqual([6, 7, 8, 9, 10, 11], sorted(cache.keys()))
 
 
-@skipIfPY3
 class TestLRUSizeCache(TestCase):
 
     def test_basic_init(self):