[New-bugs-announce] [issue16865] ctypes arrays >=2GB in length causes exception
Jeffrey Bush
report at bugs.python.org
Fri Jan 4 22:28:18 CET 2013
New submission from Jeffrey Bush:
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).
----------
components: ctypes
messages: 179080
nosy: coderforlife
priority: normal
severity: normal
status: open
title: ctypes arrays >=2GB in length causes exception
type: behavior
versions: Python 2.7
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue16865>
_______________________________________
More information about the New-bugs-announce
mailing list