- patch #1600346 submitted by Tomer Filiba
- Renamed nb_nonzero slots to nb_bool
- Renamed __nonzero__ methods to __bool__
- update core, lib, docs, and tests to match
diff --git a/Lib/test/test_richcmp.py b/Lib/test/test_richcmp.py
index f412a89..9c4a7a0 100644
--- a/Lib/test/test_richcmp.py
+++ b/Lib/test/test_richcmp.py
@@ -51,7 +51,7 @@
def __hash__(self):
raise TypeError, "Vectors cannot be hashed"
- def __nonzero__(self):
+ def __bool__(self):
raise TypeError, "Vectors cannot be used in Boolean contexts"
def __cmp__(self, other):
@@ -133,7 +133,7 @@
for ops in opmap.itervalues():
for op in ops:
- # calls __nonzero__, which should fail
+ # calls __bool__, which should fail
self.assertRaises(TypeError, bool, op(a, b))
class NumberTest(unittest.TestCase):
@@ -208,13 +208,13 @@
self.assertRaises(RuntimeError, cmp, a, b)
def test_not(self):
- # Check that exceptions in __nonzero__ are properly
+ # Check that exceptions in __bool__ are properly
# propagated by the not operator
import operator
class Exc(Exception):
pass
class Bad:
- def __nonzero__(self):
+ def __bool__(self):
raise Exc
def do(bad):