cpython: a78cbb2125a8 (original) (raw)

Mercurial > cpython

changeset 100088:a78cbb2125a8

Issue #19023: Merge ctypes doc and tests from 3.5 [#19023]

Martin Panter vadmium+py@gmail.com
date Fri, 29 Jan 2016 10:25:40 +0000
parents 0fb96a43d381(current diff)732fdd03e708(diff)
children df3290046e62
files Misc/ACKS
diffstat 4 files changed, 71 insertions(+), 11 deletions(-)[+] [-] Doc/library/ctypes.rst 60 Lib/ctypes/test/test_arrays.py 12 Lib/ctypes/test/test_pointers.py 9 Misc/ACKS 1

line wrap: on

line diff

--- a/Doc/library/ctypes.rst +++ b/Doc/library/ctypes.rst @@ -716,8 +716,8 @@ Pointer instances are created by calling >>> pi = pointer(i) >>> -Pointer instances have a :attr:contents attribute which returns the object to -which the pointer points, the i object above:: +Pointer instances have a :attr:~_Pointer.contents attribute which +returns the object to which the pointer points, the i object above:: >>> pi.contents c_long(42) @@ -2401,6 +2401,56 @@ other data types containing pointer type Arrays and pointers ^^^^^^^^^^^^^^^^^^^ -Not yet written - please see the sections :ref:ctypes-pointers and section -:ref:ctypes-arrays in the tutorial. - +.. class:: Array(*args) +

+

+ +

+ +

+ +.. class:: _Pointer +

+

+

+

--- a/Lib/ctypes/test/test_arrays.py +++ b/Lib/ctypes/test/test_arrays.py @@ -24,20 +24,24 @@ class ArrayTestCase(unittest.TestCase): self.assertEqual(len(ia), alen) # slot values ok?

+ # change the items from operator import setitem new_values = list(range(42, 42+alen)) [setitem(ia, n, new_values[n]) for n in range(alen)]

# are the items initialized to 0? ia = int_array()

# Too many initializers should be caught self.assertRaises(IndexError, int_array, range(alen2))

--- a/Lib/ctypes/test/test_pointers.py +++ b/Lib/ctypes/test/test_pointers.py @@ -56,9 +56,13 @@ class PointersTestCase(unittest.TestCase # C code: # int x = 12321; # res = &x

+ def test_callbacks_with_pointers(self): # a function type receiving a pointer PROTOTYPE = CFUNCTYPE(c_int, POINTER(c_int)) @@ -131,9 +135,10 @@ class PointersTestCase(unittest.TestCase def test_basic(self): p = pointer(c_int(42))

def test_charpp(self):

--- a/Misc/ACKS +++ b/Misc/ACKS @@ -1504,6 +1504,7 @@ Dmitry Vasiliev Sebastian Ortiz Vasquez Alexandre Vassalotti Nadeem Vawda +Sye van der Veen Frank Vercruesse Mike Verdone Jaap Vermeulen