diff --git a/lib/locking.py b/lib/locking.py
index 103d645012bf13a48f5892f16af0040c8b774f7d..b738ed64d2044e65cac3674134a83a8747d1e354 100644
--- a/lib/locking.py
+++ b/lib/locking.py
@@ -895,7 +895,6 @@ class LockSet:
     for lname in utils.UniqueSequence(names):
       try:
         lock = self.__lockdict[lname] # raises KeyError if lock is not there
-        acquire_list.append((lname, lock))
       except KeyError:
         if want_all:
           # We are acquiring all the set, it doesn't matter if this particular
@@ -904,6 +903,8 @@ class LockSet:
 
         raise errors.LockError("Non-existing lock in set (%s)" % lname)
 
+      acquire_list.append((lname, lock))
+
     # This will hold the locknames we effectively acquired.
     acquired = set()