aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndré Erdmann <dywi@mailerd.de>2014-03-25 21:52:41 +0100
committerAndré Erdmann <dywi@mailerd.de>2014-03-25 21:52:41 +0100
commitf9997f4e52f70e127432abc01df04c18760fa391 (patch)
tree7077ee8338378d505cd958629e47745b4b6bb37c /roverlay/util
parentfixme note (diff)
downloadR_overlay-f9997f4e52f70e127432abc01df04c18760fa391.tar.gz
R_overlay-f9997f4e52f70e127432abc01df04c18760fa391.tar.bz2
R_overlay-f9997f4e52f70e127432abc01df04c18760fa391.zip
fix potential python 2 issue
Python 2 checks for __nonzero__(), not __bool__(). roverlay usually relies explicit checks ("if obj.attr == $expected" or "obj.exists()" rather than "if object:"), so this is not a major issue.
Diffstat (limited to 'roverlay/util')
-rw-r--r--roverlay/util/objects.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/roverlay/util/objects.py b/roverlay/util/objects.py
index d14733e..9c73749 100644
--- a/roverlay/util/objects.py
+++ b/roverlay/util/objects.py
@@ -55,6 +55,8 @@ class SafeWeakRef ( weakref.ref ):
return self.deref_unsafe() is not None
# --- end of __bool__ (...) ---
+ __nonzero__ = __bool__
+
def __repr__ ( self ):
obj = self.deref_unsafe()
if obj:
@@ -104,6 +106,8 @@ class NoneRef ( object ):
return False
# --- end of __bool__ (...) ---
+ __nonzero__ = __bool__
+
def __repr__ ( self ):
return "<NoneRef at 0x{:x}>".format ( id ( self ) )
# --- end of __repr__ (...) ---
@@ -360,6 +364,10 @@ class ObjectView ( object ):
return bool ( self.obj_ref )
# --- end of __bool__ (...) ---
+ def __nonzero__ ( self ):
+ return self.__bool__()
+ # --- end of __nonzero__ (...) ---
+
@abstractmethod
def update ( self ):
"""Updates this view (collect data from the actual object etc.)."""