Message31819
belopolsky: _objects is only set when the c_char_p instance is created in the way you described. It will not be set if the instance is modified by a foreign function call, so this is not robust.
nnorwitz: Sure there are many ways to crash Python with ctypes, but printing c_char_p(42) should not carsh, IMO.
I believe the best strategy would be to behave this way on Windows where the check for a valid string pointer can be made:
>>> c_char_p(42)
c_char_p(0x2A)
>>> c_char("foo")
c_char('foo')
>>>
and this way on other systems:
>>> c_char_p(42)
c_char_p(0x2A)
>>> c_char_p("foo")
c_char_p(0x2A7F3B)
>>>
The attached patch fixes this for c_char_p, a similar patch should be applied to c_wchar_p.
File Added: c_char_p.patch |
|
Date |
User |
Action |
Args |
2007-08-23 14:53:10 | admin | link | issue1701409 messages |
2007-08-23 14:53:10 | admin | create | |
|