diff --git a/Lib/functools.py b/Lib/functools.py index 2c08791d4d2651b..05993163506ac52 100644 --- a/Lib/functools.py +++ b/Lib/functools.py @@ -275,29 +275,7 @@ def reduce(function, sequence, /, initial=_initial_missing): ################################################################################ -class _PlaceholderType: - """The type of the Placeholder singleton. - - Used as a placeholder for partial arguments. - """ - __instance = None - __slots__ = () - - def __init_subclass__(cls, *args, **kwargs): - raise TypeError(f"type '{cls.__name__}' is not an acceptable base type") - - def __new__(cls): - if cls.__instance is None: - cls.__instance = object.__new__(cls) - return cls.__instance - - def __repr__(self): - return 'Placeholder' - - def __reduce__(self): - return 'Placeholder' - -Placeholder = _PlaceholderType() +Placeholder = sentinel('Placeholder') # _PlaceholderType() def _partial_prepare_merger(args): if not args: @@ -440,7 +418,7 @@ def __setstate__(self, state): try: - from _functools import partial, Placeholder, _PlaceholderType + from _functools import partial, Placeholder except ImportError: pass diff --git a/Lib/test/test_functools.py b/Lib/test/test_functools.py index 6aa7916adc0bb86..0eb5efcb6e18e26 100644 --- a/Lib/test/test_functools.py +++ b/Lib/test/test_functools.py @@ -279,13 +279,6 @@ def test_placeholders_kw_restriction(self): self.assertEqual(len(actual_kwds), 1) self.assertIs(actual_kwds['a'], ALWAYS_EQ) - def test_construct_placeholder_singleton(self): - PH = self.module.Placeholder - tp = type(PH) - self.assertIs(tp(), PH) - self.assertRaises(TypeError, tp, 1, 2) - self.assertRaises(TypeError, tp, a=1, b=2) - def test_repr(self): args = (object(), object()) args_repr = ', '.join(repr(a) for a in args)