From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) by finch.gentoo.org (Postfix) with ESMTP id 6B57F13888F for ; Tue, 6 Oct 2015 04:05:58 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 8A7F921C021; Tue, 6 Oct 2015 04:05:57 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 26F2521C021 for ; Tue, 6 Oct 2015 04:05:57 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.gentoo.org (Postfix) with ESMTP id 4B42E340702 for ; Tue, 6 Oct 2015 04:05:56 +0000 (UTC) From: Mike Frysinger To: gentoo-catalyst@lists.gentoo.org Subject: [gentoo-catalyst] [PATCH] lock: rewrite delete_lock_from_path_list Date: Tue, 6 Oct 2015 00:05:54 -0400 Message-Id: <1444104354-15959-1-git-send-email-vapier@gentoo.org> X-Mailer: git-send-email 2.5.2 Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-catalyst@lists.gentoo.org Reply-to: gentoo-catalyst@lists.gentoo.org X-Archives-Salt: 153ddaf0-5198-42ac-aad4-0d72e4adf237 X-Archives-Hash: e1868eb860e6feb9c934313ce95cb262 This code looks like it attempts to remove self.lockdir from the lock_dirs_in_use list, but it doesn't seem to quite work: - it uses "for x in lock_dirs_in_use", but then indexes lock_dirs_in_use via the "i" variable - the "i" variable is set to 0, but then never incremented (looks like due to incorrect indentation) - the only way an entry would be deleted is if it happened to be in the first location of the list In the end, this looks like an ad-hoc implementation of the list .remove builtin, so just delete the code and use that. --- catalyst/lock.py | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/catalyst/lock.py b/catalyst/lock.py index c031258..25d2aa2 100644 --- a/catalyst/lock.py +++ b/catalyst/lock.py @@ -57,15 +57,9 @@ class LockDir(object): self.hardlock_paths={} def delete_lock_from_path_list(self): - i=0 try: - if LockDir.lock_dirs_in_use: - for x in LockDir.lock_dirs_in_use: - if LockDir.lock_dirs_in_use[i] == self.lockdir: - del LockDir.lock_dirs_in_use[i] - break - i=i+1 - except AttributeError: + LockDir.lock_dirs_in_use.remove(self.lockdir) + except ValueError: pass def islocked(self): -- 2.5.2