Merge "Improve Python 3.x compatibility"

This commit is contained in:
Jenkins
2013-06-05 13:42:43 +00:00
committed by Gerrit Code Review
3 changed files with 21 additions and 2 deletions

View File

@@ -211,6 +211,25 @@ Example::
LOG.error(msg % {"s_id": "1234", "m_key": "imageId"})
Python 3.x compatibility
------------------------
Nova code should stay Python 3.x compatible. That means all Python 2.x-only
constructs should be avoided. An example is
except x,y:
Use
except x as y:
instead. Other Python 3.x compatility issues, like e.g. print operator
can be avoided in new code by using
from __future__ import print_function
at the top of your module.
Creating Unit Tests
-------------------
For every new feature, unit tests should be created that both test and

View File

@@ -309,7 +309,7 @@ class ApiEc2TestCase(test.TestCase):
try:
self.ec2.create_key_pair('test')
except boto_exc.EC2ResponseError, e:
except boto_exc.EC2ResponseError as e:
if e.code == 'InvalidKeyPair.Duplicate':
pass
else:

View File

@@ -219,7 +219,7 @@ class BaseMigrationTestCase(test.TestCase):
for key, value in defaults.items():
self.test_databases[key] = value
self.snake_walk = cp.getboolean('walk_style', 'snake_walk')
except ConfigParser.ParsingError, e:
except ConfigParser.ParsingError as e:
self.fail("Failed to read test_migrations.conf config "
"file. Got error: %s" % e)
else: