[Python-checkins] r78544 - in python/trunk: Doc/library/ctypes.rst Lib/ctypes/__init__.py Lib/ctypes/test/test_sizes.py Misc/NEWS

gregory.p.smith python-checkins at python.org
Mon Mar 1 05:56:13 CET 2010


Author: gregory.p.smith
Date: Mon Mar  1 05:56:12 2010
New Revision: 78544

Log:
Adds c_ssize_t to ctypes.  issue 6729.


Modified:
   python/trunk/Doc/library/ctypes.rst
   python/trunk/Lib/ctypes/__init__.py
   python/trunk/Lib/ctypes/test/test_sizes.py
   python/trunk/Misc/NEWS

Modified: python/trunk/Doc/library/ctypes.rst
==============================================================================
--- python/trunk/Doc/library/ctypes.rst	(original)
+++ python/trunk/Doc/library/ctypes.rst	Mon Mar  1 05:56:12 2010
@@ -2248,6 +2248,13 @@
    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

Modified: python/trunk/Lib/ctypes/__init__.py
==============================================================================
--- python/trunk/Lib/ctypes/__init__.py	(original)
+++ python/trunk/Lib/ctypes/__init__.py	Mon Mar  1 05:56:12 2010
@@ -462,10 +462,13 @@
 
 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
 

Modified: python/trunk/Lib/ctypes/test/test_sizes.py
==============================================================================
--- python/trunk/Lib/ctypes/test/test_sizes.py	(original)
+++ python/trunk/Lib/ctypes/test/test_sizes.py	Mon Mar  1 05:56:12 2010
@@ -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 @@
     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()

Modified: python/trunk/Misc/NEWS
==============================================================================
--- python/trunk/Misc/NEWS	(original)
+++ python/trunk/Misc/NEWS	Mon Mar  1 05:56:12 2010
@@ -78,6 +78,8 @@
 - Issue #1068268: The subprocess module now handles EINTR in internal
   os.waitpid and os.read system calls where appropriate.
 
+- Issue #6729: Added ctypes.c_ssize_t to represent ssize_t.
+
 Extension Modules
 -----------------
 


More information about the Python-checkins mailing list