diff options
| author | Petr Viktorin <pviktori@redhat.com> | 2015-07-30 16:49:29 +0200 |
|---|---|---|
| committer | Tomas Babej <tbabej@redhat.com> | 2015-08-12 18:17:23 +0200 |
| commit | 27dabb45282911e375336f75934af9dd6cc5d963 (patch) | |
| tree | 3c8fe5255d60613fa9cd14d053b3688feed740c9 /ipapython/ipaldap.py | |
| parent | a651be3eec2a08bd2865b16b0eed767db69aab0f (diff) | |
| download | freeipa-27dabb45282911e375336f75934af9dd6cc5d963.tar.gz freeipa-27dabb45282911e375336f75934af9dd6cc5d963.tar.xz freeipa-27dabb45282911e375336f75934af9dd6cc5d963.zip | |
Modernize 'except' clauses
The 'as' syntax works from Python 2 on, and Python 3 will
drop the "comma" syntax.
Reviewed-By: Tomas Babej <tbabej@redhat.com>
Diffstat (limited to 'ipapython/ipaldap.py')
| -rw-r--r-- | ipapython/ipaldap.py | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/ipapython/ipaldap.py b/ipapython/ipaldap.py index ef7c41a37..3d38d6050 100644 --- a/ipapython/ipaldap.py +++ b/ipapython/ipaldap.py @@ -168,7 +168,7 @@ class SchemaCache(object): except ldap.SERVER_DOWN: raise errors.NetworkError(uri=url, error=u'LDAP Server Down, unable to retrieve LDAP schema') - except ldap.LDAPError, e: + except ldap.LDAPError as e: desc = e.args[0]['desc'].strip() info = e.args[0].get('info', '').strip() raise errors.DatabaseError(desc = u'uri=%s' % url, @@ -865,7 +865,7 @@ class LDAPClient(object): return datetime.datetime.strptime(val, LDAP_GENERALIZED_TIME_FORMAT) else: return target_type(val) - except Exception, e: + except Exception as e: msg = 'unable to convert the attribute %r value %r to type %s' % (attr, val, target_type) self.log.error(msg) raise ValueError(msg) @@ -927,7 +927,7 @@ class LDAPClient(object): yield except ldap.TIMEOUT: raise errors.DatabaseTimeout() - except ldap.LDAPError, e: + except ldap.LDAPError as e: desc = e.args[0]['desc'].strip() info = e.args[0].get('info', '').strip() if arg_desc is not None: @@ -984,7 +984,7 @@ class LDAPClient(object): raise errors.DatabaseError(desc=desc, info=info) except ldap.AUTH_UNKNOWN: raise errors.ACIError(info='%s (%s)' % (info,desc)) - except ldap.LDAPError, e: + except ldap.LDAPError as e: if 'NOT_ALLOWED_TO_DELEGATE' in info: raise errors.ACIError( info="KDC returned NOT_ALLOWED_TO_DELEGATE") @@ -1354,7 +1354,7 @@ class LDAPClient(object): break else: cookie = '' - except ldap.LDAPError, e: + except ldap.LDAPError as e: # If paged search is in progress, try to cancel it if paged_search and cookie: sctrls = [SimplePagedResultsControl(0, 0, cookie)] @@ -1363,7 +1363,7 @@ class LDAPClient(object): str(base_dn), scope, filter, attrs_list, serverctrls=sctrls, timeout=time_limit, sizelimit=size_limit) - except ldap.LDAPError, e: + except ldap.LDAPError as e: self.log.warning( "Error cancelling paged search: %s", e) cookie = '' @@ -1630,7 +1630,7 @@ class IPAdmin(LDAPClient): pw_name = pwd.getpwuid(os.geteuid()).pw_name self.do_external_bind(pw_name, timeout=timeout) return - except errors.NotFound, e: + except errors.NotFound as e: if autobind == AUTOBIND_ENABLED: # autobind was required and failed, raise # exception that it failed |
