summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorThomas Heller <theller@ctypes.org>2007-07-13 17:12:23 (GMT)
committerThomas Heller <theller@ctypes.org>2007-07-13 17:12:23 (GMT)
commitfa704c6adef703271844349bad94fbf7d09143d9 (patch)
tree89f2d504b9c3a9a5f852e3808a871ee1f2539b63 /Lib
parentad0cfe3dd7df3b58486e51ab881ddfe1d71d90ba (diff)
downloadcpython-fa704c6adef703271844349bad94fbf7d09143d9.zip
cpython-fa704c6adef703271844349bad94fbf7d09143d9.tar.gz
cpython-fa704c6adef703271844349bad94fbf7d09143d9.tar.bz2
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.
Diffstat (limited to 'Lib')
-rw-r--r--Lib/ctypes/__init__.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/Lib/ctypes/__init__.py b/Lib/ctypes/__init__.py
index f8b2d75..7dff3a7 100644
--- a/Lib/ctypes/__init__.py
+++ b/Lib/ctypes/__init__.py
@@ -226,6 +226,14 @@ _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)
_check_size(c_char_p, "P")
class c_void_p(_SimpleCData):