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 <rep...@bugs.python.org>
<http://bugs.python.org/issue16865>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to