lockfile: use hasattr() instead of dir()
authorZac Medico <zmedico@gentoo.org>
Thu, 9 Jun 2011 15:43:40 +0000 (08:43 -0700)
committerZac Medico <zmedico@gentoo.org>
Thu, 9 Jun 2011 15:43:40 +0000 (08:43 -0700)
pym/portage/locks.py

index 50a92006129e295138b608960b9a8627504c88c6..9ed1d6a6cfb0bfe6e7325ec412f249f1824fc37f 100644 (file)
@@ -114,7 +114,7 @@ def lockfile(mypath, wantnewlockfile=0, unlinkfile=0,
        try:
                locking_method(myfd, fcntl.LOCK_EX|fcntl.LOCK_NB)
        except IOError as e:
-               if "errno" not in dir(e):
+               if not hasattr(e, "errno"):
                        raise
                if e.errno in (errno.EACCES, errno.EAGAIN):
                        # resource temp unavailable; eg, someone beat us to the lock.