diff --git a/boltons/typeutils.py b/boltons/typeutils.py index 462d408..6a70f22 100644 --- a/boltons/typeutils.py +++ b/boltons/typeutils.py @@ -53,8 +53,11 @@ def make_sentinel(name='_MISSING', var_name=None): def __reduce__(self): return self.var_name - def __len__(self): - return 0 + def __nonzero__(self): + return False + + __bool__ = __nonzero__ + return Sentinel() diff --git a/tests/test_typeutils.py b/tests/test_typeutils.py new file mode 100644 index 0000000..80c6cc6 --- /dev/null +++ b/tests/test_typeutils.py @@ -0,0 +1,7 @@ + +from boltons.typeutils import make_sentinel + + +def test_sentinel_falsiness(): + not_set = make_sentinel('not_set') + assert not not_set