diff --git a/heat/engine/cfn/functions.py b/heat/engine/cfn/functions.py index bc46aea166..dc7fc1906e 100644 --- a/heat/engine/cfn/functions.py +++ b/heat/engine/cfn/functions.py @@ -252,7 +252,7 @@ class Select(function.Function): if (isinstance(strings, collections.Sequence) and not isinstance(strings, six.string_types)): - if not isinstance(index, (int, long)): + if not isinstance(index, six.integer_types): raise TypeError(_('Index to "%s" must be an integer') % self.fn_name) @@ -434,7 +434,8 @@ class Replace(function.Function): value = '' if not isinstance(value, - (six.string_types, int, long, float, bool)): + (six.string_types, six.integer_types, + float, bool)): raise TypeError(_('"%s" params must be strings or numbers') % self.fn_name) diff --git a/heat/engine/constraints.py b/heat/engine/constraints.py index 8adbad18ce..4da9ae31b2 100644 --- a/heat/engine/constraints.py +++ b/heat/engine/constraints.py @@ -244,7 +244,7 @@ class AnyIndexDict(collections.Mapping): self.value = value def __getitem__(self, key): - if key != self.ANYTHING and not isinstance(key, (int, long)): + if key != self.ANYTHING and not isinstance(key, six.integer_types): raise KeyError(_('Invalid key %s') % str(key)) return self.value @@ -333,7 +333,7 @@ class Range(Constraint): self.max = max for param in (min, max): - if not isinstance(param, (float, int, long, type(None))): + if not isinstance(param, (float, six.integer_types, type(None))): raise exception.InvalidSchemaError( message=_('min/max must be numeric')) @@ -402,7 +402,7 @@ class Length(Range): super(Length, self).__init__(min, max, description) for param in (min, max): - if not isinstance(param, (int, long, type(None))): + if not isinstance(param, (six.integer_types, type(None))): msg = _('min/max length must be integral') raise exception.InvalidSchemaError(message=msg) diff --git a/heat/tests/db/test_migrations.py b/heat/tests/db/test_migrations.py index 23b3f7d4ff..5a92f20a96 100644 --- a/heat/tests/db/test_migrations.py +++ b/heat/tests/db/test_migrations.py @@ -29,6 +29,7 @@ from oslo_db.sqlalchemy import test_base from oslo_db.sqlalchemy import test_migrations from oslo_db.sqlalchemy import utils from oslo_serialization import jsonutils +import six from heat.db.sqlalchemy import migrate_repo from heat.db.sqlalchemy import migration @@ -546,12 +547,7 @@ class HeatMigrationsCheckers(test_migrations.WalkVersionsMixin, # confirm the resource.id is an int and the uuid field has been # copied from the old id. for r in res_in_db: - # now sqlalchemy returns `long` for mysql - # need more convenient way for type check - if engine.name == 'mysql': - self.assertEqual(long, type(r.id)) - else: - self.assertEqual(int, type(r.id)) + self.assertIsInstance(r.id, six.integer_types) self.assertTrue(uuid_in_res_data(r.uuid)) # confirm that the new resource_id points to the correct resource.