py3k: __nonzero__ is now __bool__

This commit is contained in:
Brian Crowell 2012-10-15 21:05:26 -05:00 committed by Brian Crowell
parent 3a665a7835
commit eed042fae5

View File

@ -17,6 +17,7 @@
import Image
import _imagingmath
import sys
VERBOSE = 0
@ -84,9 +85,15 @@ class _Operand:
return _Operand(out)
# unary operators
def __nonzero__(self):
# an image is "true" if it contains at least one non-zero pixel
return self.im.getbbox() is not None
if sys.version_info >= (3,0):
def __bool__(self):
# an image is "true" if it contains at least one non-zero pixel
return self.im.getbbox() is not None
else:
def __nonzero__(self):
# an image is "true" if it contains at least one non-zero pixel
return self.im.getbbox() is not None
def __abs__(self):
return self.apply("abs", self)
def __pos__(self):