[Python-checkins] r56351 - in python/branches/release25-maint: Lib/ctypes/__init__.py Misc/NEWS

thomas.heller python-checkins at python.org
Fri Jul 13 19:07:55 CEST 2007


Author: thomas.heller
Date: Fri Jul 13 19:07:55 2007
New Revision: 56351

Modified:
   python/branches/release25-maint/Lib/ctypes/__init__.py
   python/branches/release25-maint/Misc/NEWS
Log:
Fix for SF# 1701409: segfault in c_char_p of ctypes.  The repr output
of c_char_p and c_wchar_p has changed as a sideeffect.


Modified: python/branches/release25-maint/Lib/ctypes/__init__.py
==============================================================================
--- python/branches/release25-maint/Lib/ctypes/__init__.py	(original)
+++ python/branches/release25-maint/Lib/ctypes/__init__.py	Fri Jul 13 19:07:55 2007
@@ -226,6 +226,14 @@
 
 class c_char_p(_SimpleCData):
     _type_ = "z"
+    if _os.name == "nt":
+        def __repr__(self):
+            if not windll.kernel32.IsBadStringPtrA(self, -1):
+                return "%s(%r)" % (self.__class__.__name__, self.value)
+            return "%s(%s)" % (self.__class__.__name__, cast(self, c_void_p).value)
+    else:
+        def __repr__(self):
+            return "%s(%s)" % (self.__class__.__name__, cast(self, c_void_p).value)
 _check_size(c_char_p, "P")
 
 class c_void_p(_SimpleCData):

Modified: python/branches/release25-maint/Misc/NEWS
==============================================================================
--- python/branches/release25-maint/Misc/NEWS	(original)
+++ python/branches/release25-maint/Misc/NEWS	Fri Jul 13 19:07:55 2007
@@ -26,6 +26,10 @@
 Library
 -------
 
+- Bug #1701409: Fix a segfault in printing ctypes.c_char_p and
+  ctypes.c_wchar_p when they point to an invalid location.  As a
+  sideeffect the representation of these instances has changed.
+
 - Bug #1734723: Fix repr.Repr() so it doesn't ignore the maxtuple attribute.
 
 - Bug #1728403: Fix a bug that CJKCodecs StreamReader hangs when it


More information about the Python-checkins mailing list