From eed042fae5c4fac102a39ef1bae30530505b5f7f Mon Sep 17 00:00:00 2001 From: Brian Crowell Date: Mon, 15 Oct 2012 21:05:26 -0500 Subject: [PATCH] py3k: __nonzero__ is now __bool__ --- PIL/ImageMath.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/PIL/ImageMath.py b/PIL/ImageMath.py index a9a129b19..28dd254be 100644 --- a/PIL/ImageMath.py +++ b/PIL/ImageMath.py @@ -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):