[issue23765] Remove IsBadStringPtr calls in ctypes
eryksun
report at bugs.python.org
Wed Mar 25 10:24:13 CET 2015
eryksun added the comment:
c_char_p.__repr__ (defined in __init__.py) also checks IsBadStringPtrA via FFI.
Defining the repr differently on Windows is a wart, IMO. The following repr should be used on all platforms for c_char_p:
"%s(%s)" % (self.__class__.__name__,
c_void_p.from_buffer(self).value)
On a related note, wide-character c_wchar_p uses the default _SimpleCData.__repr__, which calls the getfunc. It should be overridden in the same manner as c_char_p because this can easily segfault Python on a non-Windows platform. Even on Windows, calling IsBadStringPtrW in Z_get can't make guarantees given multiple threads. The GIL helps, but with ctypes there's a good chance that many threads are running concurrently.
----------
nosy: +eryksun
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue23765>
_______________________________________
More information about the Python-bugs-list
mailing list