From 0cf257c54f91edc1204769391381a6485d6c4808 Mon Sep 17 00:00:00 2001
From: Guido Trotter <ultrotter@google.com>
Date: Tue, 4 Mar 2008 13:17:48 +0000
Subject: [PATCH] Make LockSet.__names() return a list, not a set

Previously the private version of the __names function returned directly a set.
We'll keep this in the public interface but change the private version to a
list in order to be able to sort() its result and then loop on it, even though
we'll need to do this with the usual care that some keys may disappear in
between.

Reviewed-by: imsnah
---
 lib/locking.py | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/lib/locking.py b/lib/locking.py
index 300462108..f9b1cfcce 100644
--- a/lib/locking.py
+++ b/lib/locking.py
@@ -331,7 +331,7 @@ class LockSet:
     result after releasing the lock.
 
     """
-    return set(self.__lockdict.keys())
+    return self.__lockdict.keys()
 
   def _names(self):
     """Return a copy of the current set of elements.
@@ -343,7 +343,7 @@ class LockSet:
       result = self.__names()
     finally:
       self.__lock.release()
-    return result
+    return set(result)
 
   def acquire(self, names, blocking=1, shared=0):
     """Acquire a set of resource locks.
@@ -467,7 +467,7 @@ class LockSet:
     # conflicting add()
     self.__lock.acquire()
     try:
-      invalid_names = self.__names().intersection(names)
+      invalid_names = set(self.__names()).intersection(names)
       if invalid_names:
         # This must be an explicit raise, not an assert, because assert is
         # turned off when using optimization, and this can happen because of
-- 
GitLab