Skip to content
This repository was archived by the owner on Jan 30, 2023. It is now read-only.

Commit c84bbe1

Browse files
committed
Replace __nonzero__ with __bool__ for Python 3.
On Python 2 alias __bool__ back to __nonzero__ and delete __bool__. This allows SageObject._test_not_implemented_methods to pass on Python 2 and 3 for classes that implement this abstract interface.
1 parent 20007d5 commit c84bbe1

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/sage/categories/additive_magmas.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
# http://www.gnu.org/licenses/
99
#******************************************************************************
1010

11+
import six
12+
1113
from sage.misc.lazy_import import LazyImport
1214
from sage.misc.abstract_method import abstract_method
1315
from sage.misc.cachefunc import cached_method
@@ -766,7 +768,7 @@ class ElementMethods:
766768
# return self == self.parent().zero()
767769

768770
@abstract_method
769-
def __nonzero__(self):
771+
def __bool__(self):
770772
"""
771773
Return whether ``self`` is not zero.
772774
@@ -785,6 +787,10 @@ def __nonzero__(self):
785787
True
786788
"""
787789

790+
if six.PY2:
791+
__nonzero__ = __bool__
792+
del __bool__
793+
788794
def _test_nonzero_equal(self, **options):
789795
r"""
790796
Test that ``.__bool__()`` behave consistently

0 commit comments

Comments
 (0)