diff --git a/Lib/numbers.py b/Lib/numbers.py --- a/Lib/numbers.py +++ b/Lib/numbers.py @@ -18,7 +18,9 @@ __slots__ = () # Concrete numeric types must provide their own hash implementation - __hash__ = None + @abstractmethod + def __hash__(self): + pass ## Notes on Decimal diff --git a/Lib/test/test_abstract_numbers.py b/Lib/test/test_abstract_numbers.py --- a/Lib/test/test_abstract_numbers.py +++ b/Lib/test/test_abstract_numbers.py @@ -7,6 +7,12 @@ from test import support class TestNumbers(unittest.TestCase): + def test_instantiation(self): + import numbers + for name in numbers.__all__: + cls = getattr(numbers, name) + self.assertRaises(TypeError, cls) + def test_int(self): self.assertTrue(issubclass(int, Integral)) self.assertTrue(issubclass(int, Complex))