diff --git a/devstack/tools/ironic/scripts/configure-vm.py b/devstack/tools/ironic/scripts/configure-vm.py index 26feadd736..cc466629de 100755 --- a/devstack/tools/ironic/scripts/configure-vm.py +++ b/devstack/tools/ironic/scripts/configure-vm.py @@ -80,7 +80,7 @@ def main(): parser.add_argument('--disk-format', default='qcow2', help='Disk format to use.') args = parser.parse_args() - with file(templatedir + '/vm.xml', 'rb') as f: + with open(templatedir + '/vm.xml', 'rb') as f: source_template = f.read() params = { 'name': args.name, diff --git a/ironic/common/exception.py b/ironic/common/exception.py index 44eca54352..4352ee8bc8 100644 --- a/ironic/common/exception.py +++ b/ironic/common/exception.py @@ -77,13 +77,13 @@ class IronicException(Exception): def __str__(self): """Encode to utf-8 then wsme api can consume it as well.""" if not six.PY3: - return unicode(self.args[0]).encode('utf-8') + return six.text_type(self.args[0]).encode('utf-8') return self.args[0] def __unicode__(self): """Return a unicode representation of the exception message.""" - return unicode(self.args[0]) + return six.text_type(self.args[0]) class NotAuthorized(IronicException): diff --git a/ironic/common/utils.py b/ironic/common/utils.py index e2226c896e..5b87863181 100644 --- a/ironic/common/utils.py +++ b/ironic/common/utils.py @@ -372,18 +372,6 @@ def read_cached_file(filename, cache_info, reload_func=None): return cache_info['data'] -def file_open(*args, **kwargs): - """Open file - - see built-in file() documentation for more details - - Note: The reason this is kept in a separate module is to easily - be able to provide a stub module that doesn't alter system - state at all (for unit tests) - """ - return file(*args, **kwargs) - - def _get_hash_object(hash_algo_name): """Create a hash object based on given algorithm. diff --git a/ironic/tests/unit/api/v1/test_types.py b/ironic/tests/unit/api/v1/test_types.py index 0c7e5ce450..34f4679fdc 100644 --- a/ironic/tests/unit/api/v1/test_types.py +++ b/ironic/tests/unit/api/v1/test_types.py @@ -285,9 +285,8 @@ class TestJsonType(base.TestCase): def test_apimultitype_tostring(self): vts = str(types.jsontype) self.assertIn(str(wtypes.text), vts) - self.assertIn(str(int), vts) - if six.PY2: - self.assertIn(str(long), vts) + for int_type in six.integer_types: + self.assertIn(str(int_type), vts) self.assertIn(str(float), vts) self.assertIn(str(types.BooleanType), vts) self.assertIn(str(list), vts) diff --git a/ironic/tests/unit/common/test_exception.py b/ironic/tests/unit/common/test_exception.py index c4dee60458..443b36ae36 100644 --- a/ironic/tests/unit/common/test_exception.py +++ b/ironic/tests/unit/common/test_exception.py @@ -23,8 +23,6 @@ class TestIronicException(base.TestCase): expected = b'\xc3\xa9\xe0\xaf\xb2\xe0\xbe\x84' if six.PY3: expected = expected.decode('utf-8') - message = chr(233) + chr(0x0bf2) + chr(3972) - else: - message = unichr(233) + unichr(0x0bf2) + unichr(3972) + message = six.unichr(233) + six.unichr(0x0bf2) + six.unichr(3972) exc = exception.IronicException(message) self.assertEqual(expected, exc.__str__())