Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
735abadd
Commit
735abadd
authored
May 15, 2018
by
Segev Finer
Committed by
Serhiy Storchaka
May 15, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bpo-16865: Support arrays >=2GB in ctypes. (GH-3006)
parent
d063b84d
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
16 additions
and
8 deletions
+16
-8
Lib/ctypes/test/test_arrays.py
Lib/ctypes/test/test_arrays.py
+7
-0
Misc/NEWS.d/next/Library/2017-09-29-16-40-38.bpo-16865.l-f6I_.rst
...S.d/next/Library/2017-09-29-16-40-38.bpo-16865.l-f6I_.rst
+1
-0
Modules/_ctypes/_ctypes.c
Modules/_ctypes/_ctypes.c
+8
-8
No files found.
Lib/ctypes/test/test_arrays.py
View file @
735abadd
import
unittest
from
test.support
import
bigmemtest
,
_2G
import
sys
from
ctypes
import
*
from
ctypes.test
import
need_symbol
...
...
@@ -181,5 +183,10 @@ class ArrayTestCase(unittest.TestCase):
_type_
=
c_int
_length_
=
1.87
@
unittest
.
skipUnless
(
sys
.
maxsize
>
2
**
32
,
'requires 64bit platform'
)
@
bigmemtest
(
size
=
_2G
,
memuse
=
1
,
dry_run
=
False
)
def
test_large_array
(
self
,
size
):
c_char
*
size
if
__name__
==
'__main__'
:
unittest
.
main
()
Misc/NEWS.d/next/Library/2017-09-29-16-40-38.bpo-16865.l-f6I_.rst
0 → 100644
View file @
735abadd
Support arrays >=2GiB in :mod:`ctypes`. Patch by Segev Finer.
Modules/_ctypes/_ctypes.c
View file @
735abadd
...
...
@@ -1390,8 +1390,7 @@ PyCArrayType_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
StgDictObject
*
stgdict
;
StgDictObject
*
itemdict
;
PyObject
*
length_attr
,
*
type_attr
;
long
length
;
int
overflow
;
Py_ssize_t
length
;
Py_ssize_t
itemsize
,
itemalign
;
/* create the new instance (which is a class,
...
...
@@ -1413,14 +1412,15 @@ PyCArrayType_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
Py_XDECREF
(
length_attr
);
goto
error
;
}
length
=
PyLong_AsLongAndOverflow
(
length_attr
,
&
overflow
);
if
(
overflow
)
{
PyErr_SetString
(
PyExc_OverflowError
,
"The '_length_' attribute is too large"
);
Py_DECREF
(
length_attr
);
length
=
PyLong_AsSsize_t
(
length_attr
);
Py_DECREF
(
length_attr
);
if
(
length
==
-
1
&&
PyErr_Occurred
())
{
if
(
PyErr_ExceptionMatches
(
PyExc_OverflowError
))
{
PyErr_SetString
(
PyExc_OverflowError
,
"The '_length_' attribute is too large"
);
}
goto
error
;
}
Py_DECREF
(
length_attr
);
type_attr
=
PyObject_GetAttrString
((
PyObject
*
)
result
,
"_type_"
);
if
(
!
type_attr
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment