]> granicus.if.org Git - python/commitdiff
Issue #23765: Removed IsBadStringPtr calls in ctypes
authorSteve Dower <steve.dower@microsoft.com>
Thu, 26 Mar 2015 04:58:36 +0000 (21:58 -0700)
committerSteve Dower <steve.dower@microsoft.com>
Thu, 26 Mar 2015 04:58:36 +0000 (21:58 -0700)
Lib/ctypes/__init__.py
Misc/NEWS

index 055294c414f0364bc335b07ca489d69d7f7a564a..4cb6d0de27104b8dfb7e3208d626d4393f41e158 100644 (file)
@@ -237,14 +237,8 @@ _check_size(c_char)
 
 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)
+    def __repr__(self):
+        return "%s(%s)" % (self.__class__.__name__, c_void_p.from_buffer(self).value)
 _check_size(c_char_p, "P")
 
 class c_void_p(_SimpleCData):
@@ -259,6 +253,8 @@ from _ctypes import POINTER, pointer, _pointer_type_cache
 
 class c_wchar_p(_SimpleCData):
     _type_ = "Z"
+    def __repr__(self):
+        return "%s(%s)" % (self.__class__.__name__, c_void_p.from_buffer(self).value)
 
 class c_wchar(_SimpleCData):
     _type_ = "u"
index eafe2275e86fb5a7e76d4ff348b42cb5cbf6d983..ef2dd3de4bd850895383d81cbbe94f74c852e0bb 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -30,6 +30,8 @@ Core and Builtins
 Library
 -------
 
+- Issue #23765: Removed IsBadStringPtr calls in ctypes
+
 - Issue #22364: Improved some re error messages using regex for hints.
 
 - Issue #23742: ntpath.expandvars() no longer loses unbalanced single quotes.