changeset 8175:d1f091d4b765

py3: support __bool__ From 2to3 -f nonzero.
author Mads Kiilerich <mads@kiilerich.com>
date Sat, 23 Nov 2019 21:33:49 +0100
parents ebc21c229371
children d2904a0c5d41
files kallithea/bin/base.py kallithea/lib/auth.py kallithea/lib/rcmail/response.py
diffstat 3 files changed, 3 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/kallithea/bin/base.py	Mon Nov 25 00:15:45 2019 +0100
+++ b/kallithea/bin/base.py	Sat Nov 23 21:33:49 2019 +0100
@@ -108,7 +108,7 @@
     def __getitem__(self, key):
         return self._conf[key]
 
-    def __nonzero__(self):
+    def __bool__(self):
         if self._conf:
             return True
         return False
--- a/kallithea/lib/auth.py	Mon Nov 25 00:15:45 2019 +0100
+++ b/kallithea/lib/auth.py	Sat Nov 23 21:33:49 2019 +0100
@@ -760,7 +760,7 @@
     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.
--- a/kallithea/lib/rcmail/response.py	Mon Nov 25 00:15:45 2019 +0100
+++ b/kallithea/lib/rcmail/response.py	Sat Nov 23 21:33:49 2019 +0100
@@ -87,7 +87,7 @@
     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):