Adds c_ssize_t to ctypes. issue 6729.
This commit is contained in:
parent
3c1586ab45
commit
3c699d334a
|
@ -2248,6 +2248,13 @@ These are the fundamental ctypes data types:
|
|||
Represents the C :ctype:`size_t` datatype.
|
||||
|
||||
|
||||
.. class:: c_ssize_t
|
||||
|
||||
Represents the C :ctype:`ssize_t` datatype.
|
||||
|
||||
.. versionadded:: 2.7
|
||||
|
||||
|
||||
.. class:: c_ubyte
|
||||
|
||||
Represents the C :ctype:`unsigned char` datatype, it interprets the value as
|
||||
|
|
|
@ -462,10 +462,13 @@ _pointer_type_cache[None] = c_void_p
|
|||
|
||||
if sizeof(c_uint) == sizeof(c_void_p):
|
||||
c_size_t = c_uint
|
||||
c_ssize_t = c_int
|
||||
elif sizeof(c_ulong) == sizeof(c_void_p):
|
||||
c_size_t = c_ulong
|
||||
c_ssize_t = c_long
|
||||
elif sizeof(c_ulonglong) == sizeof(c_void_p):
|
||||
c_size_t = c_ulonglong
|
||||
c_ssize_t = c_longlong
|
||||
|
||||
# functions
|
||||
|
||||
|
|
|
@ -1,8 +1,11 @@
|
|||
# Test specifically-sized containers.
|
||||
|
||||
import unittest
|
||||
from ctypes import *
|
||||
|
||||
import sys
|
||||
import unittest
|
||||
|
||||
|
||||
class SizesTestCase(unittest.TestCase):
|
||||
def test_8(self):
|
||||
self.assertEqual(1, sizeof(c_int8))
|
||||
|
@ -23,5 +26,9 @@ class SizesTestCase(unittest.TestCase):
|
|||
def test_size_t(self):
|
||||
self.assertEqual(sizeof(c_void_p), sizeof(c_size_t))
|
||||
|
||||
def test_ssize_t(self):
|
||||
self.assertEqual(sizeof(c_void_p), sizeof(c_ssize_t))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
|
Loading…
Reference in New Issue