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 /ipalib/util.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 'ipalib/util.py')
-rw-r--r-- | ipalib/util.py | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/ipalib/util.py b/ipalib/util.py index 5a670146e..7baec85d6 100644 --- a/ipalib/util.py +++ b/ipalib/util.py @@ -83,7 +83,7 @@ def validate_host_dns(log, fqdn): 'IPA: found %d A records for %s: %s' % (len(answers), fqdn, ' '.join(str(answer) for answer in answers)) ) - except DNSException, e: + except DNSException as e: log.debug( 'IPA: DNS A record lookup failed for %s' % fqdn ) @@ -94,7 +94,7 @@ def validate_host_dns(log, fqdn): 'IPA: found %d AAAA records for %s: %s' % (len(answers), fqdn, ' '.join(str(answer) for answer in answers)) ) - except DNSException, e: + except DNSException as e: log.debug( 'IPA: DNS AAAA record lookup failed for %s' % fqdn ) @@ -186,7 +186,7 @@ def check_writable_file(filename): else: fp = open(filename, 'w') fp.close() - except (IOError, OSError), e: + except (IOError, OSError) as e: raise errors.FileError(reason=str(e)) def normalize_zonemgr(zonemgr): @@ -287,13 +287,13 @@ def normalize_sshpubkey(value): def validate_sshpubkey(ugettext, value): try: SSHPublicKey(value) - except ValueError, UnicodeDecodeError: + except ValueError as UnicodeDecodeError: return _('invalid SSH public key') def validate_sshpubkey_no_options(ugettext, value): try: pubkey = SSHPublicKey(value) - except ValueError, UnicodeDecodeError: + except ValueError as UnicodeDecodeError: return _('invalid SSH public key') if pubkey.has_options(): @@ -313,7 +313,7 @@ def convert_sshpubkey_post(ldap, dn, entry_attrs): for pubkey in pubkeys: try: pubkey = SSHPublicKey(pubkey) - except ValueError, UnicodeDecodeError: + except ValueError as UnicodeDecodeError: continue fp = pubkey.fingerprint_hex_md5() @@ -525,7 +525,7 @@ def get_reverse_zone_default(ip_address): def validate_rdn_param(ugettext, value): try: rdn = RDN(value) - except Exception, e: + except Exception as e: return str(e) return None |