Changeset - d1f091d4b765
[Not reviewed]
default
0 3 0
Mads Kiilerich - 6 years ago 2019-11-23 21:33:49
mads@kiilerich.com
Grafted from: 99c9175e6a95
py3: support __bool__

From 2to3 -f nonzero.
3 files changed with 3 insertions and 3 deletions:
0 comments (0 inline, 0 general)
kallithea/bin/base.py
Show inline comments
 
@@ -105,13 +105,13 @@ class RcConf(object):
 
        if autoload:
 
            self._conf = self.load_config()
 

	
 
    def __getitem__(self, key):
 
        return self._conf[key]
 

	
 
    def __nonzero__(self):
 
    def __bool__(self):
 
        if self._conf:
 
            return True
 
        return False
 

	
 
    def __eq__(self, other):
 
        return self._conf.__eq__(other)
kallithea/lib/auth.py
Show inline comments
 
@@ -757,13 +757,13 @@ class HasUserGroupPermissionLevelDecorat
 
class _PermsFunction(object):
 
    """Base function for other check functions with multiple permissions"""
 

	
 
    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.
 
        """
 
        raise AssertionError(self.__class__.__name__ + ' is not a bool and must be called!')
 

	
kallithea/lib/rcmail/response.py
Show inline comments
 
@@ -84,13 +84,13 @@ class MailBase(object):
 
    def __setitem__(self, key, value):
 
        self.headers[normalize_header(key)] = value
 

	
 
    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):
 
        """Returns the sorted keys."""
 
        return sorted(self.headers.keys())
 

	
0 comments (0 inline, 0 general)