diff --git a/HACKING.rst b/HACKING.rst index 307d7477..b29361a8 100644 --- a/HACKING.rst +++ b/HACKING.rst @@ -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 diff --git a/nova/tests/test_api.py b/nova/tests/test_api.py index 949f5451..3c3ac6c6 100644 --- a/nova/tests/test_api.py +++ b/nova/tests/test_api.py @@ -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: diff --git a/nova/tests/test_migrations.py b/nova/tests/test_migrations.py index 00cfdbf6..9baf9eb6 100644 --- a/nova/tests/test_migrations.py +++ b/nova/tests/test_migrations.py @@ -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: