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/nsslib.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/nsslib.py')
-rw-r--r-- | ipapython/nsslib.py | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/ipapython/nsslib.py b/ipapython/nsslib.py index def6b104e..1fb69cbd1 100644 --- a/ipapython/nsslib.py +++ b/ipapython/nsslib.py @@ -59,7 +59,7 @@ def auth_certificate_callback(sock, check_sig, is_server, certdb): # will be set to the error code matching the reason why the validation failed # and the strerror attribute will contain a string describing the reason. approved_usage = cert.verify_now(certdb, check_sig, intended_usage, *pin_args) - except Exception, e: + except Exception as e: root_logger.error('cert validation failed for "%s" (%s)', cert.subject, e.strerror) cert_is_valid = False return cert_is_valid @@ -88,7 +88,7 @@ def auth_certificate_callback(sock, check_sig, is_server, certdb): try: # If the cert fails validation it will raise an exception cert_is_valid = cert.verify_hostname(hostname) - except Exception, e: + except Exception as e: root_logger.error('failed verifying socket hostname "%s" matches cert subject "%s" (%s)', hostname, cert.subject, e.strerror) cert_is_valid = False @@ -159,7 +159,7 @@ class NSSAddressFamilyFallback(object): self._create_socket() self.sock.connect(net_addr) return - except Exception, e: + except Exception as e: root_logger.debug("Could not connect socket to %s, error: %s", net_addr, str(e)) root_logger.debug("Try to continue with next family...") @@ -199,7 +199,7 @@ class NSSConnection(httplib.HTTPConnection, NSSAddressFamilyFallback): ssl.clear_session_cache() try: nss.nss_shutdown() - except NSPRError, e: + except NSPRError as e: if e.errno != error.SEC_ERROR_NOT_INITIALIZED: raise e @@ -236,7 +236,7 @@ class NSSConnection(httplib.HTTPConnection, NSSAddressFamilyFallback): self.sock.set_ssl_option(ssl.SSL_HANDSHAKE_AS_CLIENT, True) try: self.sock.set_ssl_version_range(self.tls_version_min, self.tls_version_max) - except NSPRError, e: + except NSPRError as e: root_logger.error('Failed to set TLS range to %s, %s' % (self.tls_version_min, self.tls_version_max)) raise self.sock.set_ssl_option(ssl_require_safe_negotiation, False) @@ -289,7 +289,7 @@ class NSSConnection(httplib.HTTPConnection, NSSAddressFamilyFallback): httplib.HTTPConnection.endheaders(self) else: httplib.HTTPConnection.endheaders(self, message) - except NSPRError, e: + except NSPRError as e: self.close() raise e |