Commit 7f9e56cf authored by Vincent Pelletier's avatar Vincent Pelletier Committed by Vincent Pelletier

all: Reduce differences with python3.

Using only 2to3 conversions which are python2-compatible.
parent 719959e0
...@@ -625,7 +625,7 @@ class CertificateAuthority(object): ...@@ -625,7 +625,7 @@ class CertificateAuthority(object):
self._renewCAIfNeeded() self._renewCAIfNeeded()
result = [] result = []
iter_key_pair = iter(self._ca_key_pairs_list) iter_key_pair = iter(self._ca_key_pairs_list)
first_key_pair = iter_key_pair.next() first_key_pair = next(iter_key_pair)
previous_crt_pem = utils.dump_certificate(first_key_pair['crt']) previous_crt_pem = utils.dump_certificate(first_key_pair['crt'])
previous_key = first_key_pair['key'] previous_key = first_key_pair['key']
for key_pair in iter_key_pair: for key_pair in iter_key_pair:
......
This diff is collapsed.
...@@ -107,7 +107,7 @@ def canConnect(address): # pragma: no cover ...@@ -107,7 +107,7 @@ def canConnect(address): # pragma: no cover
""" """
try: try:
socket.create_connection(address) socket.create_connection(address)
except socket.error, e: except socket.error as e:
if e.errno == errno.ECONNREFUSED: if e.errno == errno.ECONNREFUSED:
return False return False
raise raise
...@@ -334,7 +334,7 @@ class CaucaseTest(unittest.TestCase): ...@@ -334,7 +334,7 @@ class CaucaseTest(unittest.TestCase):
new_key_path, new_key_path,
), ),
) )
except SystemExit, e: except SystemExit as e:
return e.code # pragma: no cover return e.code # pragma: no cover
except: # pylint: disable=bare-except except: # pylint: disable=bare-except
return 1 return 1
...@@ -896,7 +896,7 @@ class CaucaseTest(unittest.TestCase): ...@@ -896,7 +896,7 @@ class CaucaseTest(unittest.TestCase):
client = CaucaseClient(self._caucase_url + '/cas') client = CaucaseClient(self._caucase_url + '/cas')
try: try:
client.createCertificateSigningRequest('Not actually a CSR') client.createCertificateSigningRequest('Not actually a CSR')
except CaucaseError, e: except CaucaseError as e:
self.assertEqual(e.args[0], 400, e) self.assertEqual(e.args[0], 400, e)
else: # pragma: no cover else: # pragma: no cover
raise AssertionError('Did not raise CaucaseError(400, ...)') raise AssertionError('Did not raise CaucaseError(400, ...)')
......
...@@ -264,7 +264,7 @@ def _verifyCertificateChain(cert, trusted_cert_list, crl): ...@@ -264,7 +264,7 @@ def _verifyCertificateChain(cert, trusted_cert_list, crl):
except ( except (
crypto.X509StoreContextError, crypto.X509StoreContextError,
crypto.Error, crypto.Error,
), e: ) as e:
raise CertificateVerificationError( raise CertificateVerificationError(
'Certificate verification error: %s' % str(e), 'Certificate verification error: %s' % str(e),
) )
......
...@@ -572,13 +572,13 @@ class Application(object): ...@@ -572,13 +572,13 @@ class Application(object):
raise InsufficientStorage raise InsufficientStorage
except exceptions.NotJSON: except exceptions.NotJSON:
raise BadRequest('Invalid json payload') raise BadRequest('Invalid json payload')
except exceptions.CertificateAuthorityException, e: except exceptions.CertificateAuthorityException as e:
raise BadRequest(str(e)) raise BadRequest(str(e))
except Exception: except Exception:
environ['wsgi.errors'].write('Unhandled exception\n') environ['wsgi.errors'].write('Unhandled exception\n')
traceback.print_exc(file=environ['wsgi.errors']) traceback.print_exc(file=environ['wsgi.errors'])
raise ApplicationError raise ApplicationError
except ApplicationError, e: except ApplicationError as e:
status = e.status status = e.status
header_list = e.response_headers header_list = e.response_headers
result = [str(x) for x in e.args] result = [str(x) for x in e.args]
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment