Skip to content

Commit

Permalink
Don't patch QPyNullVariant if it doesn't exist
Browse files Browse the repository at this point in the history
  • Loading branch information
NathanW2 committed Jun 11, 2013
1 parent 052669f commit 0fd5fd1
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions python/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,17 @@
# This will get replaced with a git SHA1 when you do a git archive
__revision__ = '$Format:%H$'

from PyQt4.QtCore import QPyNullVariant
from types import MethodType
try:
# Add a __nonzero__ method onto QPyNullVariant so we can check for null values easier.
# >>> value = QPyNullVariant("int")
# >>> if value:
# >>> print "Not a null value"
from types import MethodType
from PyQt4.QtCore import QPyNullVariant
def __nonzero__(self):
return False

# Add a __nonzero__ method onto QPyNullVariant so we can check for null values easier.
# >>> value = QPyNullVariant("int")
# >>> if value:
# >>> print "Not a null value"
def __nonzero__(self):
return False
QPyNullVariant.__nonzero__ = MethodType(__nonzero__, None, QPyNullVariant)
except ImportError:
pass

QPyNullVariant.__nonzero__ = MethodType(__nonzero__, None, QPyNullVariant)

0 comments on commit 0fd5fd1

Please sign in to comment.