# HG changeset patch # User Mads Kiilerich # Date 2019-11-23 21:33:49 # Node ID d1f091d4b7656161f5d4c238e7f95a7d2eb0c7cc # Parent ebc21c2293717d3c6af9798aea8e71072d69aa25 py3: support __bool__ From 2to3 -f nonzero. diff --git a/kallithea/bin/base.py b/kallithea/bin/base.py --- a/kallithea/bin/base.py +++ b/kallithea/bin/base.py @@ -108,7 +108,7 @@ class RcConf(object): def __getitem__(self, key): return self._conf[key] - def __nonzero__(self): + def __bool__(self): if self._conf: return True return False diff --git a/kallithea/lib/auth.py b/kallithea/lib/auth.py --- a/kallithea/lib/auth.py +++ b/kallithea/lib/auth.py @@ -760,7 +760,7 @@ class _PermsFunction(object): def __init__(self, *required_perms): self.required_perms = required_perms # usually very short - a list is thus fine - def __nonzero__(self): + def __bool__(self): """ Defend against accidentally forgetting to call the object and instead evaluating it directly in a boolean context, which could have security implications. diff --git a/kallithea/lib/rcmail/response.py b/kallithea/lib/rcmail/response.py --- a/kallithea/lib/rcmail/response.py +++ b/kallithea/lib/rcmail/response.py @@ -87,7 +87,7 @@ class MailBase(object): def __delitem__(self, key): del self.headers[normalize_header(key)] - def __nonzero__(self): + def __bool__(self): return self.body is not None or len(self.headers) > 0 or len(self.parts) > 0 def keys(self):