Replace dict.has_key with the 'in' operator

The deprecated has_key method will be removed from dicts in Python 3.

For custom dict-like classes, has_key() is kept on Python 2,
but disabled for Python 3.

Reviewed-By: Tomas Babej <tbabej@redhat.com>
This commit is contained in:
Petr Viktorin
2015-07-30 17:29:39 +02:00
committed by Tomas Babej
parent 8b88caa110
commit 6a741b51da
14 changed files with 56 additions and 55 deletions

View File

@@ -692,7 +692,7 @@ class SessionAuthManager(object):
def unregister(self, name):
self.debug('SessionAuthManager.unregister: name=%s', name)
if not self.auth_managers.has_key(name):
if name not in self.auth_managers:
raise KeyError('cannot unregister auth manager named "%s", does not exist',
name)
del self.auth_managers[name]
@@ -1259,7 +1259,7 @@ def release_ipa_ccache(ccache_name):
do we'll remove them.
'''
if os.environ.has_key('KRB5CCNAME'):
if 'KRB5CCNAME' in os.environ:
if ccache_name != os.environ['KRB5CCNAME']:
root_logger.error('release_ipa_ccache: ccache_name (%s) != KRB5CCNAME environment variable (%s)',
ccache_name, os.environ['KRB5CCNAME'])