diff options
author | Thomas Heller <theller@ctypes.org> | 2008-07-15 17:03:08 (GMT) |
---|---|---|
committer | Thomas Heller <theller@ctypes.org> | 2008-07-15 17:03:08 (GMT) |
commit | c0b2a807ff9ce7d2c0c83ee808678eb841aa9778 (patch) | |
tree | 5ecf61706a8a77f736e65e36edb79922f428b9c5 /Lib | |
parent | 6d6bd4436a08e557cc7cb52d6ae26f8662063f50 (diff) | |
download | cpython-c0b2a807ff9ce7d2c0c83ee808678eb841aa9778.zip cpython-c0b2a807ff9ce7d2c0c83ee808678eb841aa9778.tar.gz cpython-c0b2a807ff9ce7d2c0c83ee808678eb841aa9778.tar.bz2 |
Issue #3258: Fix an assertion error (in debug build) and a crash (in
release build) when the format string of a pointer to an incomplete
structure is created.
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/ctypes/test/test_pep3118.py | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/Lib/ctypes/test/test_pep3118.py b/Lib/ctypes/test/test_pep3118.py index cf628d8..119b0ad 100644 --- a/Lib/ctypes/test/test_pep3118.py +++ b/Lib/ctypes/test/test_pep3118.py @@ -33,6 +33,8 @@ class memoryview(object): def normalize(format): # Remove current endian specifier and white space from a format # string + if format is None: + return "" format = format.replace(OTHER_ENDIAN, THIS_ENDIAN) return re.sub(r"\s", "", format) @@ -105,6 +107,14 @@ class EmptyStruct(Structure): class aUnion(Union): _fields_ = [("a", c_int)] +class Incomplete(Structure): + pass + +class Complete(Structure): + pass +PComplete = POINTER(Complete) +Complete._fields_ = [("a", c_int)] + ################################################################ # # This table contains format strings as they look on little endian @@ -162,6 +172,16 @@ native_types = [ # the pep does't support unions (aUnion, "B", None, aUnion), + ## pointer to incomplete structure + (Incomplete, "B", None, Incomplete), + (POINTER(Incomplete), "&B", None, POINTER(Incomplete)), + + # 'Complete' is a structure that starts incomplete, but is completed after the + # pointer type to it has been created. + (Complete, "T{<l:a:}", None, Complete), + # Unfortunately the pointer format string is not fixed... + (POINTER(Complete), "&B", None, POINTER(Complete)), + ## other # function signatures are not implemented |