diff roundup/cgi/templating.py @ 5404:3757449e00c4

Python 3 preparation: use __bool__ instead of __nonzero__. Tool-assisted patch. __nonzero__ = __bool__ included for Python 2 compatibility.
author Joseph Myers <jsm@polyomino.org.uk>
date Tue, 24 Jul 2018 23:50:25 +0000
parents 88dbacd11cd1
children 3fa026621f69
line wrap: on
line diff
--- a/roundup/cgi/templating.py	Tue Jul 24 23:49:13 2018 +0000
+++ b/roundup/cgi/templating.py	Tue Jul 24 23:50:25 2018 +0000
@@ -1343,8 +1343,10 @@
             return cmp(self._value, other._value)
         return cmp(self._value, other)
 
-    def __nonzero__(self):
+    def __bool__(self):
         return not not self._value
+    # Python 2 compatibility:
+    __nonzero__ = __bool__
 
     def isset(self):
         """Is my _value not None?"""
@@ -3224,7 +3226,9 @@
         return getattr(self, name)
 
     def __getitem__(self, key): return self
-    def __nonzero__(self): return 0
+    def __bool__(self): return 0
+    # Python 2 compatibility:
+    __nonzero__ = __bool__
     def __str__(self): return '[%s]'%self.__description
     def __repr__(self): return '<MissingValue 0x%x "%s">'%(id(self),
         self.__description)

Roundup Issue Tracker: http://roundup-tracker.org/