This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author theller
Recipients
Date 2007-04-20.19:52:03
SpamBayes Score
Marked as misclassified
Message-id
In-reply-to
Content
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
History
Date User Action Args
2007-08-23 14:53:10adminlinkissue1701409 messages
2007-08-23 14:53:10admincreate