The environment is Windows 8 Pro 64-bit running Python 64-bit in the WinPython distribution. Python is v2.7.3 built on Apr 10 2012. I first found this with create_string_buffer however I found out that it happens with an even simpler example.
The following code throws an AttributeException: class must define a _length_ attribute, which must be a positive integer.
import ctypes
c_char * int(2*1024*1024*1024) # 2GB, also fails with long() instead of int()
However the following works
import ctypes
c_char * int(2*1024*1024*1024-1) # 1 byte less than 2GB
This is the same with the other c_ types (not limited to size of memory since c_int * int(2*1024*1024*1024-1) works and would be nearly 4 times the size of the failed c_char one). |