From bf3fe7c08e129ac9a89e3a3e52613e63299779e1 Mon Sep 17 00:00:00 2001 From: "Mike C. Fletcher" Date: Sat, 28 Dec 2019 11:48:43 -0500 Subject: [PATCH] Explicitly add nonzero methods for base latebind classes --- OpenGL/latebind.py | 4 +++- accelerate/src/latebind.pyx | 5 +++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/OpenGL/latebind.py b/OpenGL/latebind.py index dc28dc28..3b01133f 100644 --- a/OpenGL/latebind.py +++ b/OpenGL/latebind.py @@ -29,7 +29,9 @@ def finalise( self ): return final callable """ - + def __nonzero__(self): + """Resolve our final call and check for empty/nonzero on it""" + return bool(self.getFinalCall()) def __call__( self, *args, **named ): """Call self._finalCall, calling finalise() first if not already called diff --git a/accelerate/src/latebind.pyx b/accelerate/src/latebind.pyx index f2748240..f009a76e 100644 --- a/accelerate/src/latebind.pyx +++ b/accelerate/src/latebind.pyx @@ -14,6 +14,11 @@ cdef class LateBind: def finalise( self ): """Finalise our target to our final callable object""" + def __nonzero__(self): + """Resolve our final call and check for empty/nonzero on it""" + return bool(self.getFinalCall()) + __bool__ = __nonzero__ + def getFinalCall( self ): """Retrieve and/or bind and retrieve final call""" if not self._finalCall: