eryksun added the comment: > So the repr that's there for c_char_p is currently:: > "%s(%s)" % (self.__class__.__name__, cast(self, c_void_p).value)
I suggested switching to using from_buffer: c_void_p.from_buffer(self).value from_buffer is more efficient. cast() is imlemented as an FFI call. There's also another approach using the buffer protocol: int.from_bytes(self, sys.byteorder) > I prefer the former (remove c_char_p.__repr__ completely), but > the latter is clearly there for some reason. Any opinions? It's there for same reason I suggested overriding c_wchar_p.__repr__. Getting the repr of an object shouldn't segfault the interpreter. The existing check with IsBadStringPtrA is bogus in a multithreaded environment. The repr should just show the address. At least that won't crash. A topic for another discussion is disabling the SEH handler because it's not used consistently anyway (e.g. to guard pointer and CData base pointer access). To compensate, the faulthandler could be enhanced. It could call the CRT's __pxcptinfoptrs (not documented, but it should be) to get the Windows EXCEPTION_POINTERS record. This would enable at least an improved error message, e.g. "Segmentation fault reading [addr]" and "Segmentation fault writing [addr]". The funny thing is the current faulthandler example uses ctypes.string_at, which, because it's implemented as an FFI call guarded by the SEH handler, just raises OSError on Windows. ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue23765> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com