Mercurial > p > roundup > code
diff roundup/cgi/templating.py @ 5457:a35d4cc8cd1a
fix MissingValue / MockNull to return False on __bool__ and add a
__contains__ to support 'in' operator correctly
| author | Christof Meerwald <cmeerw@cmeerw.org> |
|---|---|
| date | Mon, 23 Jul 2018 21:45:05 +0100 |
| parents | 754be676ccc8 |
| children | ad8031290639 |
line wrap: on
line diff
--- a/roundup/cgi/templating.py Mon Jul 23 21:43:39 2018 +0100 +++ b/roundup/cgi/templating.py Mon Jul 23 21:45:05 2018 +0100 @@ -3240,9 +3240,10 @@ return getattr(self, name) def __getitem__(self, key): return self - def __bool__(self): return 0 + def __bool__(self): return False # Python 2 compatibility: __nonzero__ = __bool__ + def __contains__(self, key): return False def __str__(self): return '[%s]'%self.__description def __repr__(self): return '<MissingValue 0x%x "%s">'%(id(self), self.__description)
