diff options
author | Thomas Heller <theller@ctypes.org> | 2006-11-24 18:45:39 (GMT) |
---|---|---|
committer | Thomas Heller <theller@ctypes.org> | 2006-11-24 18:45:39 (GMT) |
commit | 25d208bd464aa6b1bde8a30cc71327133edaeeb3 (patch) | |
tree | 9f6eb3a83b3b491bd7fe8a1165c68d6f31e9193d /Lib | |
parent | a3c77677caf9724ac2a9ba1183d3e594d78dfc5c (diff) | |
download | cpython-25d208bd464aa6b1bde8a30cc71327133edaeeb3.zip cpython-25d208bd464aa6b1bde8a30cc71327133edaeeb3.tar.gz cpython-25d208bd464aa6b1bde8a30cc71327133edaeeb3.tar.bz2 |
Fix bug #1598620: A ctypes structure cannot contain itself.
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/ctypes/test/test_structures.py | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/Lib/ctypes/test/test_structures.py b/Lib/ctypes/test/test_structures.py index 8a4531d..613163d 100644 --- a/Lib/ctypes/test/test_structures.py +++ b/Lib/ctypes/test/test_structures.py @@ -381,5 +381,35 @@ class PointerMemberTestCase(unittest.TestCase): s.p = None self.failUnlessEqual(s.x, 12345678) +class TestRecursiveStructure(unittest.TestCase): + def test_contains_itself(self): + class Recursive(Structure): + pass + + try: + Recursive._fields_ = [("next", Recursive)] + except AttributeError, details: + self.failUnless("Structure or union cannot contain itself" in + str(details)) + else: + self.fail("Structure or union cannot contain itself") + + + def test_vice_versa(self): + class First(Structure): + pass + class Second(Structure): + pass + + First._fields_ = [("second", Second)] + + try: + Second._fields_ = [("first", First)] + except AttributeError, details: + self.failUnless("_fields_ is final" in + str(details)) + else: + self.fail("AttributeError not raised") + if __name__ == '__main__': unittest.main() |