diff --git a/swift/common/utils.py b/swift/common/utils.py index e4c2bccf3c..13dd314514 100644 --- a/swift/common/utils.py +++ b/swift/common/utils.py @@ -4972,11 +4972,15 @@ except TypeError: class ShardRangeOuterBound(object): """ - A custom singleton type used for the outer bounds of ShardRanges. + A custom singleton type to be subclassed for the outer bounds of + ShardRanges. """ _singleton = None def __new__(cls): + if cls is ShardRangeOuterBound: + raise TypeError('ShardRangeOuterBound is an abstract class; ' + 'only subclasses should be instantiated') if cls._singleton is None: cls._singleton = super(ShardRangeOuterBound, cls).__new__(cls) return cls._singleton diff --git a/test/unit/common/test_utils.py b/test/unit/common/test_utils.py index 7bcf9f996d..cf01ce90b3 100644 --- a/test/unit/common/test_utils.py +++ b/test/unit/common/test_utils.py @@ -7732,6 +7732,9 @@ class TestShardRange(unittest.TestCase): self.ts_iter = make_timestamp_iter() def test_min_max_bounds(self): + with self.assertRaises(TypeError): + utils.ShardRangeOuterBound() + # max self.assertEqual(utils.ShardRange.MAX, utils.ShardRange.MAX) self.assertFalse(utils.ShardRange.MAX > utils.ShardRange.MAX)