summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorThomas Heller <theller@ctypes.org>2008-05-29 19:54:39 (GMT)
committerThomas Heller <theller@ctypes.org>2008-05-29 19:54:39 (GMT)
commit7dca3ebc97661da9fe2945b9c65d58c234d10629 (patch)
tree454671e8739b3c1d3e6605a73496714b36c8f25b /Lib
parent61dbbf02b61ee752e14c4155acc02fe641febd48 (diff)
downloadcpython-7dca3ebc97661da9fe2945b9c65d58c234d10629.zip
cpython-7dca3ebc97661da9fe2945b9c65d58c234d10629.tar.gz
cpython-7dca3ebc97661da9fe2945b9c65d58c234d10629.tar.bz2
Merged revisions 63791-63792 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ........ r63791 | thomas.heller | 2008-05-29 21:18:12 +0200 (Do, 29 Mai 2008) | 1 line Fix compiler warning. ........ r63792 | thomas.heller | 2008-05-29 21:42:34 +0200 (Do, 29 Mai 2008) | 1 line ctypes NULL function pointers have a boolean False value now. ........
Diffstat (limited to 'Lib')
-rw-r--r--Lib/ctypes/test/test_pointers.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/Lib/ctypes/test/test_pointers.py b/Lib/ctypes/test/test_pointers.py
index df62d04..05b180e 100644
--- a/Lib/ctypes/test/test_pointers.py
+++ b/Lib/ctypes/test/test_pointers.py
@@ -175,5 +175,13 @@ class PointersTestCase(unittest.TestCase):
self.assertRaises(TypeError, c_void_p, 3.14) # make sure floats are NOT accepted
self.assertRaises(TypeError, c_void_p, object()) # nor other objects
+ def test_pointers_bool(self):
+ # NULL pointers have a boolean False value, non-NULL pointers True.
+ self.failUnlessEqual(bool(POINTER(c_int)()), False)
+ self.failUnlessEqual(bool(pointer(c_int())), True)
+
+ self.failUnlessEqual(bool(CFUNCTYPE(None)(0)), False)
+ self.failUnlessEqual(bool(CFUNCTYPE(None)(42)), True)
+
if __name__ == '__main__':
unittest.main()